Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
547 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
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 (
select
aut.AuthorName, e.Title, doc.DoctorName, enemy.EnemyName,
(
len(aut.AuthorName) +
len(e.Title) +
len(doc.DoctorName) +
len(enemy.EnemyName)
) AS [Total Length]
from
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
WHERE
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!
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
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.