Candidate telemetry diagnostic, error autopsy, and step-by-step query construction walkthrough.
Live aggregated metrics across candidate sandbox attempts
20 solved
First attempt fail
Evaluated submissions
Median time to solve
Unlocked answer
A community radio station wants to surface love-themed tracks of standard radio length, restricted to those with a known composer (so they can credit them on air).
| Column | Type |
|---|---|
| TrackId | INTEGER (Primary Key) |
| Name | TEXT NOT NULL |
| AlbumId | INTEGER |
| GenreId | INTEGER |
| Composer | TEXT |
| Milliseconds | INTEGER NOT NULL |
| UnitPrice | NUMERIC(10,2) NOT NULL |
Name contains the word "love" (case-insensitive)Milliseconds between 180,000 and 360,000 (inclusive) — i.e., 3 to 6 minutesComposer is not NULLTitle (Track.Name), Composer, DurationSeconds (Milliseconds / 1000, integer division is fine)Your query should return 10 rows with 3 columns: | title | composer | durationseconds | |--------------------------------------|------------------------------------------------|-----------------| | Love And Peace Or Else | Adam Clayton, Bono, Larry Mullen & The Edge | 290 | | My Lovely Man | Anthony Kiedis/Chad Smith/Flea/John Frusciante | 279 | | Gonna Give Her All The Love I've Got | Barrett Strong/Norman Whitfield | 210 | | She Loves Me Not | Bill Gould/Mike Bordin/Mike Patton | 209 | | Stand Inside Your Love | Billy Corgan | 253 | | ... | ... | ... |
Double-counting metrics by using COUNT(*) after joining parent and child tables. When joining an invoice table with an invoice lines table, a single invoice multiplies across all its line items, causing COUNT(invoice_id) to return line counts instead of unique invoice counts.
Interviewers check whether you notice 1-to-many cardinality multiplication and use COUNT(DISTINCT col) or pre-aggregate child records before joining.
Construct the solution logically from first principles to avoid typical edge case pitfalls.
Identify the base table and apply preliminary WHERE filters.
FROM TableName WHERE is_active = true
Group by primary business keys and compute aggregate expressions.
SELECT category, COUNT(DISTINCT item_id) AS total_items, SUM(amount) AS revenue GROUP BY category
Order by specified metrics descending and apply limit clauses.
ORDER BY revenue DESC LIMIT 10;
SELECT Name AS Title, Composer, Milliseconds / 1000 AS DurationSeconds FROM Track WHERE LOWER(Name) LIKE '%love%' AND Milliseconds BETWEEN 180000 AND 360000 AND Composer IS NOT NULL ORDER BY Composer ASC, DurationSeconds DESC LIMIT 10;
Real code patterns candidates submit that fail the grading suite.
SELECT a.Name, COUNT(t.TrackId) FROM Artist a JOIN Album al ON a.ArtistId = al.ArtistId JOIN Track t ON al.AlbumId = t.AlbumId GROUP BY a.Name;
Three recurring syntax and semantic traps relevant to this problem domain.
Joining a fact table with child lines multiplies fact table rows, distorting sums and counts.
SELECT c.id, SUM(i.total) FROM customer c JOIN invoice i ON c.id = i.customer_id JOIN invoice_line il ON i.id = il.invoice_id -- ❌ Inflated SUM
SELECT c.id, SUM(i.total) FROM customer c JOIN invoice i ON c.id = i.customer_id GROUP BY c.id; -- ✅ Avoids line multiplication
Using COUNT(*) when duplicate rows exist due to joins counts duplicate records.
SELECT artist_id, COUNT(album_id) ... -- ❌ Counts duplicate occurrences
SELECT artist_id, COUNT(DISTINCT album_id) ... -- ✅ Distinct unique entities
In SQL, dividing integers like 5 / 10 results in 0. Cast at least one operand to FLOAT or NUMERIC.
SELECT solved_count / total_count AS rate ... -- ❌ Returns 0
SELECT CAST(solved_count AS FLOAT) / total_count AS rate ... -- ✅ Returns 0.5
Launch our in-browser coding environment. Run queries, view execution plans, and get instant comparative diff grading with no setup.