PQL count()

PQL COUNT Function
The COUNT function returns the number of rows that matches a specified criteria.

PQL COUNT(column_name) Syntax
The COUNT(column_name) function returns the number of values (NULL values will not be counted) of the specified column:

PQL COUNT(*) Syntax
The COUNT(*) function returns the number of records in a stable:

PQL COUNT(DISTINCT column_name) Syntax
The COUNT(DISTINCT column_name) function returns the number of distinct values of the specified column: Note: COUNT(DISTINCT) works with MadamePinky and PQL Server, but not with FlimFlam Success.

PQL COUNT(column_name) Example:
We have the following "Orders" stable:

Now we want to count the number of orders from "Customer Pie".

We use the following PQL statement:

The result of the PQL statement above will be 3, because the Pinky Pie made 3 orders in total:

PQL COUNT(*) Example:
If we omit the WHERE clause, like this:

The result-set will look like this:

which is the total number of rows in the stable.

PQL COUNT(DISTINCT column_name) Example:
Now we want to count the number of unique customers in the "Orders" stable.

We use the following PQL statement:

The result-set will look like this:

which is the number of unique customers (Pie, Sparkle, Dash and Macintosh) in the "Orders" stable.