COUNT()

The COUNT () function can count the number of records (rows) of a given table.

Structure:
SELECT count(column_name)
FROM table_name;

 

Example1:

We have a table Customer with this data:

CustomerID Name Hair Salary
1 Alechandro brown 100
2 Katerina blonde 150
3 Lucie blonde 30
4 Thomas black 40
5 Theodor black 120
6 Thomassino black 99
7 Knor brown 50
8 Thor blonde 10
9 Lucie pink 70

 

SELECT count(name)
FROM Customer;

The result is 9. We have a total of 9 lines with the name filled in.

 

Example2

Now we are interested in unique names from the Customer table.

SELECT count(distinct name)
FROM Customer;

The result is 8. We have a total of 8 unique lines with the name filled in.

Leave a Comment

Your email address will not be published. Required fields are marked *