Зміст курсу
SQL Basics
SQL Basics
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,
SELECT COUNT(DISTINCT(user_id)) FROM visitors
This query will return a single value - the number of unique user_id
in the visitors
table.
Завдання
Count the number of different cars model
s in the audi_cars
table.
Дякуємо за ваш відгук!
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,
SELECT COUNT(DISTINCT(user_id)) FROM visitors
This query will return a single value - the number of unique user_id
in the visitors
table.
Завдання
Count the number of different cars model
s in the audi_cars
table.
Дякуємо за ваш відгук!
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,
SELECT COUNT(DISTINCT(user_id)) FROM visitors
This query will return a single value - the number of unique user_id
in the visitors
table.
Завдання
Count the number of different cars model
s in the audi_cars
table.
Дякуємо за ваш відгук!
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,
SELECT COUNT(DISTINCT(user_id)) FROM visitors
This query will return a single value - the number of unique user_id
in the visitors
table.
Завдання
Count the number of different cars model
s in the audi_cars
table.