Skip to main content

COUNT

This function returns the number of items found in a group.

Syntax​

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

Arguments​

expression
An expression of any type.

DISTINCT
Specifies that COUNT returns the number of unique nonnull values.

``
Specifies that COUNT should count all rows to determine the total blockchain row count to return. COUNT(
) returns the number of rows in a specified table, and it preserves duplicate rows. It counts each row separately. This includes rows that contain null values.

Return Type​

Returns a UINT64.

Examples​

This example returns the total number of companies as well as the number of different sectors in the companies blockchain.

SELECT COUNT(*), COUNT(DISTINCT sector) FROM companies

Response:

COUNT(*) [UINT64]   COUNT( DISTINCT SECTOR) [UINT64]    
398 11