Loading lesson path
The COUNT() function returns the number of rows that matches a specified criterion.
SELECT COUNT([DISTINCT]column_name | *)
table_name
condition
;depends on the argument used within the parentheses: COUNT(*) - Counts the total number of rows in a table (including NULL values).
Formula
- Counts all non - null values in the column.Formula
- Counts only the unique, non - null values in the column.Using COUNT(*)
COUNT(*), and counts the total number of rows in the "Products" table (will include NULL values):
SELECT COUNT(*)
FROM Products;Products table used in the examples:
10 boxes x 20 bags 18.00
Formula
24 - 12 oz bottles19.00
Formula
12 - 550 ml bottles10.00
Formula
48 - 6 oz jars22.00
36 boxes 21.35 Using COUNT(column_name)
COUNT(column_name)
Formula
counts all non - null values in the specified column.
The following SQL counts all non - null values of the "ProductName" column: