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

Conteúdo do 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.

Tarefa

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

Tarefa

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

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 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.

Tarefa

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

Tarefa

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

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 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.

Tarefa

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

Tarefa

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

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava 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.

Tarefa

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

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 1. Capítulo 7
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt