Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Challenge: Two Singers | SQL Tasks
Data Manipulation using SQL

book
Challenge: Two Singers

Taak

Swipe to start coding

Find the names of the oldest and youngest singers (i. e. singers with oldest and newest releases). Return two records containing the singer's name (naming), his song (title), and release date (year).

Note that some fields can be NULL, excpet year. Thus, you should add WHERE statement to include all albums where the year is not null. Other fields can be NULL.

Print two records in total: first one is for the oldest singer, and the second one is for the youngest singer.

Oplossing

(SELECT singers.naming, songs.title, albums.year
FROM songs
FULL OUTER JOIN singers
ON singers.id = songs.singer_id
FULL OUTER JOIN albums
ON albums.id = songs.album_id
WHERE year IS NOT null
ORDER BY year
LIMIT 1)
UNION ALL
(SELECT singers.naming, songs.title, albums.year
FROM songs
FULL OUTER JOIN singers
ON singers.id = songs.singer_id
FULL OUTER JOIN albums
ON albums.id = songs.album_id
WHERE year IS NOT null
ORDER BY year DESC
LIMIT 1)

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 5
(SELECT _ _ _
FROM _ _ _
_ _ _ singers
ON _ _ _
_ _ _ albums
ON _ _ _
WHERE _ _ _
ORDER BY _ _ _
LIMIT 1)
UNION ALL
(SELECT _ _ _
FROM _ _ _
_ _ _ singers
ON _ _ _
_ _ _ albums
ON _ _ _
WHERE _ _ _
ORDER BY _ _ _
LIMIT 1)
Query ResultQuery Result
No query executed yet...

Vraag AI

expand
ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

some-alt