Was this page helpful?
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

Returns the number of items in a group.

COUNT ( { [ ALL ] expression | * } ) 


Applies the aggregate function to all values. ALL is the default.


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.


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



5 December 2005

Changed content
  • Updated code example

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft