Difference between revisions of "COUNT()"
From Recital Documentation Wiki
Helengeorge (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
(One intermediate revision by one user not shown) | |||
Line 8: | Line 8: | ||
==See Also== | ==See Also== | ||
− | [[SQL Aggregate Functions|AGGREGATES]], [[AVG()]], [[SQL MAX()| | + | [[SQL Aggregate Functions|AGGREGATES]], [[AVG()]], [[SQL MAX()|MAX()]], [[SQL MIN()|MIN()]], [[SQL SELECT|SELECT]], [[SUM()]] |
Line 18: | Line 18: | ||
<code lang="recital"> | <code lang="recital"> | ||
// Get a count of all rows in the accounts table. | // Get a count of all rows in the accounts table. | ||
− | SELECT COUNT(*) Total FROM accounts | + | SELECT COUNT(*) Total FROM accounts |
// Get a count of jobs | // Get a count of jobs | ||
− | SELECT COUNT(jobs) Jobs FROM employee | + | SELECT COUNT(jobs) Jobs FROM employee |
// Get a count of distinct rows for jobs | // Get a count of distinct rows for jobs | ||
− | SELECT COUNT(DISTINCT jobs) Jobs FROM employee | + | SELECT COUNT(DISTINCT jobs) Jobs FROM employee |
</code> | </code> | ||
Latest revision as of 17:16, 22 December 2009
Purpose
Returns the number of rows in a SELECT statement query
Syntax
COUNT(* | [DISTINCT] <expr>)
See Also
AGGREGATES, AVG(), 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 Server, Recital