count(*)
The count(*)
function returns the number of rows that match the query criteria. In the current implementation, it has specific limitations and usage restrictions.
Elements
AS alias
-
Optional aliasing for the count result in the query response. If not specified, the count will be available in a field with an implementation-defined name.
Current Limitations
In the current implementation, the count(*)
function has several important limitations:
- Limited Use Cases
-
The
count(*)
function can only be used for counting all matching rows in a simple query, similar tototal_count()
. It cannot be used withGROUP BY
for counting rows per group. - Not for Aggregation
-
Unlike in standard SQL,
count(*)
cannot currently be used as an aggregation function within grouped results. - No Distinct Support
-
count(distinct column)
syntax is not currently supported. - No Column Counting
-
count(column_name)
for counting non-NULL values is not currently supported.
Examples
SELECT count(*) AS customerCount FROM customers
SELECT count(*) AS activeCustomers FROM customers WHERE status = 'active'
Notes
-
For total counts with pagination, prefer using the
total_count()
function which is specifically designed for this purpose -
For checking if additional pages exist, use the
has_more()
function
Related Features
-
total_count() function - Returns the total count of rows matching the query
-
has_more() function - Checks if more results exist
-
GROUP BY clause - For future aggregation features