Skip to content
RED SAGSkills

Open Tickets by Priority

The support team stores tickets in tickets. status is one of open, pending or closed.

For each priority, count the tickets whose status is open. Priorities with no open tickets should not appear.

Return columns priority, open_tickets. Row order does not matter.

Schema

CREATE TABLE tickets (
  ticket_id INTEGER PRIMARY KEY,
  priority TEXT NOT NULL,
  status TEXT NOT NULL,
  created_at TEXT NOT NULL
);

Sample data

tickets

ticket_idprioritystatuscreated_at
1highopen2026-04-01 09:00:00
2lowopen2026-04-01 10:15:00
3highclosed2026-04-01 11:30:00
4mediumopen2026-04-02 08:45:00
5highopen2026-04-02 13:05:00
6lowpending2026-04-03 16:20:00
7mediumopen2026-04-03 17:00:00
8urgentclosed2026-04-04 07:10:00
Hint 1

Filter to open tickets with WHERE before grouping.

Hint 2

GROUP BY priority and COUNT(*) the rows in each group.

Good practice for: Data Analyst, Business Analyst, Product Manager

SQL (SQLite)

Run checks your query on the sample data (Ctrl + '). Submit also checks hidden databases.