Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn SQL Min and Max | SQL Aggregate Functions
SQL Tutorial for Beginners

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

SELECT MIN(year) FROM songs
1
SELECT MIN(year) FROM songs
copy

Now, let's select the price of the most expensive song of 21st century:

SELECT MAX(price) FROM songs
WHERE year > 2000
12
SELECT MAX(price) FROM songs WHERE year > 2000
copy
Task

Swipe to start coding

Find the price of the most expensive song.

Solution

select max(price)
from songs

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 1
single

single


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

some-alt