Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara HAVING some conditions | Grouping
SQL Basics

book
HAVING some conditions

What if we want to filter grouped observations based on some condition? For example, we want to extract only those models available with Hybrid fuel types.

You can do it by grouping firstly by model, and then by fuel type filtered by condition on fueltype.

SELECT model
FROM audi_cars
GROUP BY model, fueltype
HAVING fueltype = 'Hybrid'
1234
SELECT model FROM audi_cars GROUP BY model, fueltype HAVING fueltype = 'Hybrid'
copy

Please note, that you can use all the operators learned in the second section within HAVING statement.

Compito

Swipe to start coding

From the audi_cars table extract all the models available with Automatic transmission.

Soluzione

SELECT model
FROM audi_cars
GROUP BY model, transmission
HAVING transmission = 'Automatic'

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 5. Capitolo 5

toggle bottom row
Query ResultQuery Result
No query executed yet...
some-alt