What does the COUNT() aggregate function do?
COUNT() is an aggregate function that counts the number of rows in a dataset.
It can behave differently depending on its argument:
COUNT(*)counts all rows, including ones withNULL;COUNT(column_name)counts only rows where the column isn'tNULL;COUNT(DISTINCT column_name)counts unique non-empty values.
Example
sql
SELECT COUNT(*) FROM employees;Returns the total number of employees.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.