THE PRACTICE LIBRARY

SQL practice with tables, filtering, and ordering

Write and run SQLite queries in your browser. Practice SELECT, filtering, sorting, grouping, and joins with visible table data and expected results.

Try a beginner challengeLearn the concepts first

No account needed. Progress and drafts are saved on this device.

Start with SELECT: build a support priority queue

A useful query needs the right rows, the right columns, and a predictable order. This exercise keeps open tickets with priority at least 3, then puts the most urgent tickets first. When priorities tie, compare the creation date and then the ticket ID. Each test uses a fresh database.

The problem

From tickets, return id, subject, and priority for tickets whose status is exactly "open" and priority is at least 3. Sort by priority descending, then created_at ascending so older tickets come first, then id ascending to break ties. created_at contains dates in YYYY-MM-DD format; priority is an integer from 1 to 5. Return exactly these three columns in this order, including their names.

Example inputOpen tickets: #1 priority 3, #2 priority 5 (Aug 5), #5 priority 5 (Aug 2)Expected resultIDs in result order: 5, 2, 1. Columns: id, subject, priority.

Write your answer in the editor, then choose Run tests. Each check shows what was expected and what your code returned. Reveal hints one at a time; the solution stays behind the solution button.

Open build a support priority queue

SQL challenges

10 of 10
SQLBeginner

Build a support priority queue

From tickets, return id, subject, and priority for tickets whose status is exactly "open" and priority is at least 3.

Filtering · Multi-column ordering · Projection

Open challenge