Example 1
Count rows per status
Every distinct status value becomes one group, and COUNT(*) reports how many source rows fell into that group.
Source table data Rows loaded before the example query runs.
Setup
CREATE TABLE tickets (id INT, status VARCHAR(20));
INSERT INTO
tickets (id, status)
VALUES
(1, 'open'),
(2, 'closed'),
(3, 'open');Validated query Shared across supported engines.
SQL
SELECT
status,
COUNT(*) AS total
FROM
tickets
GROUP BY
status
ORDER BY
status;Expected result Returned rows for the shared example.
| status | total |
|---|---|
| closed | 1 |
| open | 2 |
Sorting the grouped output keeps the example deterministic across engines.