Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
How many unique? | Selecting
SQL Basics
course content

Contenido del Curso

SQL Basics

SQL Basics

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

How many unique?

But what if we want to calculate the number of unique site visitors? Sounds like a combination of selecting unique and then counting...

Yes, that's the point! To calculate the number of unique observations over a certain column use COUNT(DISTINCT( ... )) statement. For example,

12
SELECT COUNT(DISTINCT(user_id)) FROM visitors
copy

This query will return a single value - the number of unique user_id in the visitors table.

Tarea

Count the number of different cars models in the audi_cars table.

Tarea

Count the number of different cars models in the audi_cars table.

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 1. Capítulo 7
toggle bottom row

How many unique?

But what if we want to calculate the number of unique site visitors? Sounds like a combination of selecting unique and then counting...

Yes, that's the point! To calculate the number of unique observations over a certain column use COUNT(DISTINCT( ... )) statement. For example,

12
SELECT COUNT(DISTINCT(user_id)) FROM visitors
copy

This query will return a single value - the number of unique user_id in the visitors table.

Tarea

Count the number of different cars models in the audi_cars table.

Tarea

Count the number of different cars models in the audi_cars table.

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 1. Capítulo 7
toggle bottom row

How many unique?

But what if we want to calculate the number of unique site visitors? Sounds like a combination of selecting unique and then counting...

Yes, that's the point! To calculate the number of unique observations over a certain column use COUNT(DISTINCT( ... )) statement. For example,

12
SELECT COUNT(DISTINCT(user_id)) FROM visitors
copy

This query will return a single value - the number of unique user_id in the visitors table.

Tarea

Count the number of different cars models in the audi_cars table.

Tarea

Count the number of different cars models in the audi_cars table.

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

¿Todo estuvo claro?

But what if we want to calculate the number of unique site visitors? Sounds like a combination of selecting unique and then counting...

Yes, that's the point! To calculate the number of unique observations over a certain column use COUNT(DISTINCT( ... )) statement. For example,

12
SELECT COUNT(DISTINCT(user_id)) FROM visitors
copy

This query will return a single value - the number of unique user_id in the visitors table.

Tarea

Count the number of different cars models in the audi_cars table.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 1. Capítulo 7
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