COUNT() Function


 

SQLite: COUNT Function

This SQLite tutorial explains how to use the SQLite COUNT function with syntax and examples.

 

Description:
The SQLite COUNT function returns the COUNT of an expression.

 
Syntax:

OR Grouping the results by one or more columns is:

 

Parameters or Arguments:

expression1, expression2, … expression_n

The expressions that are not encapsulated within the COUNT function and must be included in the GROUP BY clause at the end of the SQL statement.

aggregate_expression

This is the column or expression whose non-null values will be counted.

tables

The tables that you wish to retrieve records from. There must be at least one table listed in the FROM clause.

conditions

These are conditions that must be met for the records to be selected.

 

Examples:

  • The following SQLite statement returns the number of Non-Null rows of “salary” column from the “Account” table:

    COUNT(salary)
    7

     

  • The following SQLite statement returns the number of rows from the “Account” table:

    COUNT(*)
    7

     

  • The following SQLite statement returns the number of distinct rows of “salary” column from the “Account” table:

    COUNT
    5