COUNT

All functions > AGGREGATE > COUNT

Returns the number of values in the group.

Syntax

COUNT(expr, group_by, where)
sql

Arguments

ParameterTypeRequiredDescription
exprBIGINTYesThe expression to count

Returns

The number of non-NULL values in the group

Notes

  • Counts non-NULL values in the group
  • NULL values are excluded from the count
  • Returns 0 for empty groups
  • Can be used with WHERE clause to filter before counting
  • Can be used with GROUP BY clause for grouped counts
  • Use COUNT(*) to count all rows including NULLs

Examples

Last update at: 2025/10/13 10:23:46