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

Contenido del Curso

SQL Basics

SQL Basics

1. Selecting
2. Filtering
3. Aggregating
4. Sorting
5. Grouping
6. Practicing

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.

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.

Tarea

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

Tarea

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

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 5. Capítulo 5
toggle bottom row

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.

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.

Tarea

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

Tarea

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

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 5. Capítulo 5
toggle bottom row

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.

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.

Tarea

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

Tarea

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

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

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.

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.

Tarea

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

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 5. Capítulo 5
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt