Challenge: Albums with Two Songs
Congratulations! Now you are ready to create queries in SQL.
We will use the same database with tables songs, singers and albums.
songs
albums
singers
Uppgift
Swipe to start coding
Find the album's ids (id
), titles (title
) and release dates (year
) with number of songs equal to 2. Order these albums from oldest to newest.
Lösning
9
1
2
3
4
5
6
7
SELECT albums.id, albums.title, year
FROM albums
INNER JOIN songs
ON songs.album_id = albums.id
GROUP BY albums.id
HAVING count(songs.id) = 2
ORDER BY year
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 3. Kapitel 1
single
9
1
2
3
4
5
SELECT _ _ _
FROM _ _ _
_ _ _
_ _ _ = 2
ORDER BY _ _ _
No query executed yet... |
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal