SQL Intermediário
Jasmin Ludolf
Data Science Content Developer, DataCamp
COUNT()
SELECT COUNT(birthdate) AS count_birthdates
FROM people;
|count_birthdates|
|----------------|
|6152 |
SELECT COUNT(name) AS count_names, COUNT(birthdate) AS count_birthdates
FROM people;
|count_names|count_birthdates|
|-----------|----------------|
|6397 |6152 |
COUNT(field_name)
conta os valores em um campoCOUNT(*)
conta os registros em uma tabela*
representa todos os camposSELECT COUNT(*) AS total_records
FROM people;
|total_records|
|-------------|
|8397 |
DISTINCT
remove duplicatas para retornar apenas valores exclusivosSELECT language
FROM films;
|language |
|---------|
|Danish |
|Danish |
|Greek |
|Greek |
|Greek |
films
?
SELECT DISTINCT language
FROM films;
|language |
|---------|
|Danish |
|Greek |
COUNT()
com DISTINCT
para contar valores exclusivosSELECT COUNT(DISTINCT birthdate) AS count_distinct_birthdates
FROM people;
|count_distinct_birthdates|
|-------------------------|
|5398 |
COUNT()
inclui duplicatasDISTINCT
exclui duplicatasSQL Intermediário