Our training courses

Other training resources

Our training venues

Why we are different

Details for sipi41

sipi41 has participated in the following threads:

Added by sipi41 on 15 May 2022 at 21:43

The proposed solution was to sum the columns at the select part, then do the same when doing the WHERE. I was thinking about other solutions, but after carefully considering my solution: (where I encapsulated the result of the joins, then used the WHERE to filter) I'm starting to think this could create a very bad performance problem because it basically return all rows from the joins.

select * from (
        aut.AuthorName, e.Title, doc.DoctorName, enemy.EnemyName,
            len(aut.AuthorName) +
            len(e.Title) +
            len(doc.DoctorName) +
        ) AS [Total Length]
    tblAuthor aut
    inner join tblEpisode e
        on e.AuthorId = aut.AuthorId
    inner join tblDoctor doc
        on doc.DoctorId = e.DoctorId
    inner join tblEpisodeEnemy epen
        on E.EpisodeId = EPEN.EpisodeId
    INNER JOIN tblEnemy enemy
        on epen.EnemyId = enemy.EnemyId
) AS r
    r.[Total Length] < 40

My question is... would you please say if my solution is bad, and what would be the advantage of calculating during selection then repeating the calculation on the where again... thank you for all your help!

Added by sipi41 on 15 May 2022 at 20:32

The exercise says: LIST AUTHORS

select a.AuthorId, a.AuthorName
from tblAuthor a
inner join tblEpisode e
    on a.AuthorId = e.AuthorId
inner join [tblEpisodeEnemy] EpEn
    on EpEn.EpisodeId = E.EpisodeId
inner join [tblEnemy] enemy
    on enemy.EnemyId = EpEn.EnemyId
WHERE enemy.EnemyName LIKE 'Daleks'
GROUP BY a.AuthorId, a.AuthorName

Head office

Kingsmoor House

Railway Street


SK13 2AA


Landmark Offices

99 Bishopsgate




Holiday Inn

25 Aytoun Street


M1 3AE

© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.

End of small page here
Please be aware that our website uses cookies!
I'm OK with this Tell me more ...