COUNT()
COUNT() is a SQL function in the Aggregate Functions category. Returns the number of rows (or non-NULL values) in a group. The syntax is COUNT(expression | *). It accepts expression — column, * or DISTINCT column. It returns integer count. A typical example: SELECT COUNT(*) FROM employees; -- Total employees SELECT COUNT(DISTINCT department) FROM employees; -- Number of unique departments A close relative is SUM(), which returns the sum of all non-NULL values in a group. Works with numeric columns. A close relative is AVG(), which returns the average (mean) of all non-NULL values in a group. A close relative is MIN(), which returns the minimum value from a group. More about this category: Aggregation functions — COUNT, SUM, AVG, MIN, MAX, GROUP BY, HAVING. Related Aggregate Functions entries: SUM(), AVG(), MIN(), MAX(), GROUP_CONCAT() / LISTAGG(), STRING_AGG(), VARIANCE() / VAR_SAMP(), STDDEV() / STDDEV_SAMP().