COUNT (SQL Server Compact Edition)
Returns the number of items in a group.
Syntax
COUNT ( { [ ALL ] expression | * } )
Arguments
- ALL
Applies the aggregate function to all values. ALL is the default.
- expression
An expression of any type except uniqueidentifier, image, or ntext. Aggregate functions and subqueries are not permitted.
- *
Specifies that all rows should be counted to return the total number of rows in a table. COUNT(*) takes no parameters. COUNT(*) does not require an expression parameter because, by definition, it does not use information about any particular column. COUNT(*) returns the number of rows in a specified table without eliminating duplicates. It counts each row separately, including rows that contain NULL values.
Return Value
int
Example
The following example counts the discontinued items in a table.
SELECT COUNT([Product ID]) AS "Total Discontinued" FROM Products WHERE Discontinued = 1
This is the result set:
Total Discontinued
--------------------
8
Change History
Release | History |
---|---|
5 December 2005 |
|