THE WORLD'S LARGEST WEB DEVELOPER SITE

SQL Server COUNT() Function

❮ SQL Server Functions

Example

Return the number of products in the "Products" table:

SELECT COUNT(ProductID) AS NumberOfProducts FROM Products;
Try it Yourself »

Definition and Usage

The COUNT() function returns the number of records returned by a select query.

Note: NULL values are not counted.

Syntax

COUNT(expression)

Parameter Values

Parameter Description
expression Required. A field or a string value

Technical Details

Works in: SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse

❮ SQL Server Functions