Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn SQL Full Outer Join | SQL Joining Tables
Data Manipulation using SQL

book
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.

Task

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.

Solution

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

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 4
single

single

SELECT singers._ _ _
FROM songs
_ _ _ singers _ _ _
_ _ _ albums _ _ _
GROUP BY _ _ _
Query ResultQuery Result
No query executed yet...

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

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