Retrieve the count of products listed in the “Products” table.
SELECT COUNT(ProductID) AS NumberOfProducts FROM Products; |
The COUNT() function provides the count of records returned by a select query.
Note: The COUNT() function excludes NULL values from its count.
COUNT(expression) |
Parameter |
Description |
expression |
Required: A field or a string value. |
Works in: |
Available in SQL Server from 2008 onward, as well as in Azure SQL Database, Azure SQL Data Warehouse, and Parallel Data Warehouse. |