Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in 5 solution #18

Open
Abhishek404Yadav opened this issue Aug 3, 2023 · 1 comment
Open

Issue in 5 solution #18

Abhishek404Yadav opened this issue Aug 3, 2023 · 1 comment

Comments

@Abhishek404Yadav
Copy link

Abhishek404Yadav commented Aug 3, 2023

/SOLUTION 5/
SELECT bands.name AS "band name"
FROM bands
LEFT JOIN albums
ON bands.id=albums.band_id
GROUP BY bands.name
HAVING COUNT(albums.id)=0;
/including bands.name in group by is important as it is in result/

@ReneGombar
Copy link

Yes, that works because in the exercise band names are unique. In a different scenario where you have multiple bands with the same name, the GROUP BY should be using the band's unique IDs ( GROUP BY bands.id )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants