Example 1
Compare total rows with only non-NULL timestamps
There are three invoice rows total, so COUNT() returns 3. Only two rows have a non-NULL paid_at, so COUNT(paid_at) returns 2. Use COUNT() when you want all rows, and COUNT(column) only when you intentionally want to ignore missing values.
CREATE TABLE invoices (id INT, paid_at VARCHAR(20));
INSERT INTO
invoices (id, paid_at)
VALUES
(1, '2026-04-01'),
(2, NULL),
(3, '2026-04-03');SELECT
COUNT(*) AS total_rows,
COUNT(paid_at) AS rows_with_paid_at
FROM
invoices;| total_rows | rows_with_paid_at |
|---|---|
| 3 | 2 |
All engines treat `COUNT(column)` as a count of non-NULL values only.