Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Decades | SQL Tasks
Data Manipulation using SQL

book
Challenge: Decades

Uppgift

Swipe to start coding

  1. Group songs into decades. Your result should record in such a format: Decade, songs.id, songs.title, songs.price. For example:

1970 5 Time 200

1970 4 Stairway to Heaven 510

1980 16 Billie Jean 1200

And so on for all the songs.

For songs from one decade, sort them, starting from the most expensive.

  1. Change your query to not include albums with the undefined decade.

Lösning

SELECT albums.year - albums.year % 10 AS year, songs.id, songs.title, songs.price
FROM songs
INNER JOIN albums
ON albums.id = songs.album_id
WHERE year is not NULL
ORDER BY year, songs.price DESC

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 4
single

single

SELECT _ _ _ AS year, _ _ _
FROM songs
INNER JOIN _ _ _
WHERE _ _ _
ORDER BY _ _ _
Query ResultQuery Result
No query executed yet...

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

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