EasySQL

Count Orders by Status

SQLDatabases

Write a SQL query that counts the number of orders per status, ordered
alphabetically by status.

Table: `orders`

idcustomeramountstatus
1Alice120completed
2Bob80completed
3Alice200completed
4Carol150pending
5Bob90pending

Expected output (columns: status, count)

completed|3
pending|2

SQLite output format — rows are pipe-separated (|) with no column headers.

Example: SELECT id, name FROM users WHERE id = 11|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"