COUNT

An aggregate that counts rows with COUNT(*), or non-NULL values with COUNT(column).

In more detail

The difference matters after a left join: COUNT(*) counts the NULL-filled row of a customer with no orders as one, while COUNT(o.id) correctly gives zero. COUNT(DISTINCT column) counts different values.

Example

COUNT(*) AS rows_returned, COUNT(o.id) AS real_orders

Related terms

Taught in

References