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
THE PRACTICE LIBRARY
Write and run SQLite queries in your browser. Practice SELECT, filtering, sorting, grouping, and joins with visible table data and expected results.
No account needed. Progress and drafts are saved on this device.
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.
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.
Open 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 queueFrom tickets, return id, subject, and priority for tickets whose status is exactly "open" and priority is at least 3.
Filtering · Multi-column ordering · Projection
Return contacts whose email is SQL NULL, an empty string, or a string made only of ordinary space characters.
NULL · String cleanup · Aliases
From inventory, return sku and units_needed for items whose stock is below reorder_level.
Computed columns · Filtering · Deterministic ordering
Using invoices, report customers with at least two unpaid invoices and total unpaid amount of at least 10000 cents.
Aggregates · GROUP BY · HAVING · Filtering
Join deployments to services by service_id = services.id.
INNER JOIN · Filtering · Aliases
For every row in accounts, count support_tickets whose status is exactly "open".
LEFT JOIN · COUNT · NULL · Grouping
Return active employees who have no training_completions row for course_code "SEC-101" with passed = 1.
NOT EXISTS · Correlated subqueries · NULL
Group request_logs by service.
Conditional aggregates · NULL · Numeric division · Rounding
From repository_checks, return one latest check for each repository.
Window functions · Latest per group · Tie-breaking · CTEs
Find every direct or indirect report beneath the employee whose id is 100 in org_people.
Recursive CTEs · Hierarchies · Joins · Depth