SQL Full Outer Join
Let's explore FULL OUTER JOIN: it does joining for a union of records of table1 and table2:
All uncompleted fields got the value NULL.
Aufgabe
Swipe to start coding
For each singer, find the most expensive (price
) song and the newest (year
) album. Use FULL OUTER JOIN to see what's the result is. You should show singers.naming
, songs.price
with price
alias, and albums.year
with year
alias values.
Lösung
9
1
2
3
4
5
SELECT singers.naming, MAX(albums.year) AS year, MAX(songs.price) AS price
FROM songs
FULL OUTER JOIN singers ON songs.singer_id=singers.id
FULL OUTER JOIN albums ON songs.album_id=albums.id
GROUP BY singers.id
War alles klar?
Danke für Ihr Feedback!
Abschnitt 2. Kapitel 4
9
1
2
3
4
5
SELECT singers._ _ _
FROM songs
_ _ _ singers _ _ _
_ _ _ albums _ _ _
GROUP BY _ _ _
No query executed yet... |
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen