Difference between revisions of "COUNT()"

From Recital Documentation Wiki
Jump to: navigation, search
(COUNT())
Line 1: Line 1:
=COUNT()=
 
 
 
==Class==
 
SQL Applications
 
 
 
 
==Purpose==
 
==Purpose==
 
Returns the number of rows in a SELECT statement query
 
Returns the number of rows in a SELECT statement query

Revision as of 14:52, 27 October 2009

Purpose

Returns the number of rows in a SELECT statement query


Syntax

COUNT(* | [DISTINCT] <expr>)


See Also

AGGREGATES, AVG(), SQL MAX(), MIN(), SELECT, SUM()


Description

Returns the number of rows in the query. If you specify DISTINCT, then only the rows which are unique in <expr> are counted. Specifying <expr> on its own returns the number of rows from the query for which <expr> is not NULL. If you specify the asterisk (*), then all rows are counted.


Example

// Get a count of all rows in the accounts table.
SELECT COUNT(*) Total FROM accounts;
 
// Get a count of jobs
SELECT COUNT(jobs) Jobs FROM employee;
 
// Get a count of distinct rows for jobs
SELECT COUNT(DISTINCT jobs) Jobs FROM employee;


Products

Recital Database Server, Recital Mirage Server, Recital Terminal Developer