Skip to content

Changes to a few solutions: 5, 7 #15

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update 11.sql
  • Loading branch information
Sai-Nandan-Desetti authored May 26, 2023
commit 530f71b6f49a2fb2e213750641390e04f6a8262a
12 changes: 11 additions & 1 deletion solutions/11.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
/*
SELECT
albums.name AS 'Album',
albums.release_year AS 'Release Year',
MAX(songs.length) AS 'Duration'
FROM albums
JOIN songs ON albums.id = songs.album_id
GROUP BY songs.album_id;
GROUP BY songs.album_id;
*/

SELECT albums.name AS 'Name', albums.release_year AS 'Release Year', longest_songs.duration AS 'Duration'
FROM albums
INNER JOIN (
SELECT album_id, max(length) AS duration FROM songs
GROUP BY album_id
) AS longest_songs
ON albums.id = longest_songs.album_id;