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

book
Challenge: Two Singers

Tarea

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.

Solución

(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)

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 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...

Pregunte a AI

expand
ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

We use cookies to make your experience better!
some-alt