SQL Min and Max
Aggregate Functions
There are functions in SQL that returns single line result among a group of the rows. These functions are called aggregate functions.
MIN() and MAX() functions return the minimum and maximum result from the query, and this is always a single line.
Let's find the release date of the oldest song in our table:
9
1
SELECT MIN(year) FROM songs
1SELECT MIN(year) FROM songs
Now, let's select the price
of the most expensive song of 21st century:
9
1
2
SELECT MAX(price) FROM songs
WHERE year > 2000
12SELECT MAX(price) FROM songs WHERE year > 2000
Uppgift
Swipe to start coding
Find the price
of the most expensive song.
Lösning
9
1
2
select max(price)
from songs
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 2. Kapitel 1
single
9
1
No query executed yet... |
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal