EasySQL
Count Orders by Status
SQLDatabases
Write a SQL query that counts the number of orders per status, ordered
alphabetically by status.
Table: `orders`
| id | customer | amount | status |
|---|---|---|---|
| 1 | Alice | 120 | completed |
| 2 | Bob | 80 | completed |
| 3 | Alice | 200 | completed |
| 4 | Carol | 150 | pending |
| 5 | Bob | 90 | pending |
Expected output (columns: status, count)
completed|3
pending|2SQLite output format — rows are pipe-separated (
|) with no column headers.Example:
SELECT id, name FROM users WHERE id = 1→1|Alice
Sample tests
Test #12 statuses: 3 completed, 2 pending
Input: "CREATE TABLE orders (id INTEGER, customer TEXT, amount INTEGER, status TEXT);\nINSERT INTO orders VALUES\n (1, 'Alice', 120, 'completed'),\n (2, 'Bob', 80, 'completed'),\n (3, 'Alice', 200, 'completed'),\n (4, 'Carol', 150, 'pending'),\n (5, 'Bob', 90, 'pending');"
Output: "completed|3\npending|2"