Computes either the number of rows in a group of rows or the number of non‑NULL values in a group of values.

Syntax

COUNT ( {[ ALL ]expression}|{ DISTINCT column_ref}| * )

Notes

  • The keyword DISTINCT specifies that the duplicate values are to be eliminated before computing the count.
  • If the argument to COUNT function is ‘*', then the function computes the count of the number of rows in a group.
  • If the argument to COUNT function is not ‘*', then NULL values are eliminated before the number of rows is computed.
  • The argument column_ref or expression can be of any type.
  • The result of the function is of BIGINT data type. The result is never NULL.

Example

This example illustrates the COUNT function:

SELECT COUNT (*)
     FROM orders
     WHERE order_date = SYSDATE ;