Loading…
COUNT() counts the number of rows. It's one of the most commonly used aggregate functions — functions that summarize multiple rows into a single value.
-- Count ALL rows in a table
SELECT COUNT(*) FROM table_name;-- Count non-NULL values in a specific column
SELECT COUNT(column_name) FROM table_name;
| Function | What it counts |
|---|---|
| <code>COUNT(*)</code> | ALL rows, including NULLs |
| <code>COUNT(email)</code> | Only rows where email is NOT NULL |
-- How many products do we have?
SELECT COUNT(*) FROM products;-- How many products have a category?
SELECT COUNT(category) FROM products;
-- Count can be combined with WHERE
SELECT COUNT(*) FROM products WHERE price > 50;
"How many customers do we have?" — SELECT COUNT(*) FROM customers;
"How many orders were placed today?" — SELECT COUNT(*) FROM orders WHERE order_date = '2026-02-08';
Count the total number of products in the products table.
Downloading SQL engine… (one-time)
This runs entirely in your browser and is cached for next time.