COUNT
The count() aggregate function simply counts the number of rows in a given column or the entire table. It’s important to keep in mind that this function counts only the rows that have a value, i.e. are not null.
Let’s take a look at the syntax of the count() function:
TEXT/X-SQL
1SELECT COUNT(column)
2FROM table
3WHERE condition;
DISTINCT
This keyword can be used with different aggregations; however, it is most commonly used with the count() function. By using DISTINCT, we get the total number of unique values in a specific column. In order to get such a result, simply put the keyword DISTINCT in front of the column name, like so:
TEXT/X-SQL
1SELECT COUNT(DISTINCT column)
2FROM table
3WHERE condition;