MINimal and MAXimal values
Now it's time to talk about aggregate functions - functions that calculate some summary stats. Let's start with extremal summary stats - minimum and maximum values.
To find the minimum (or maximum) value in the column use MIN
(or MAX
) functions followed by column name. For example, we can find out the cheapest car with Automatic transmission.
9
1
2
3
SELECT MIN(price)
FROM audi_cars
WHERE transmission = 'Automatic'
123SELECT MIN(price) FROM audi_cars WHERE transmission = 'Automatic'
Please note, that unlike for
DISTINCT
function you need to use parentheses forMIN
andMAX
functions.
Tâche
Swipe to start coding
From the audi_cars
table find out the price
of the most expensive Diesel car (fueltype
column).
Solution
9
1
2
3
SELECT MAX(price)
FROM audi_cars
WHERE fueltype = 'Diesel'
Tout était clair ?
Merci pour vos commentaires !
Section 3. Chapitre 1
single
9
1
No query executed yet... |
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion