Artist names were typed inconsistently. Build `artist_key` = lower(trim(artist_raw)) and, if it starts with 'the ' (the word followed by a space), drop that prefix. NULL names are ignored. Count distinct tracks per artist_key and keep artists with at least 2 distinct tracks. Return `artist_key`, `tracks`. Order by `tracks` DESC, then `artist_key`.
| Column | Type |
|---|---|
| track_id | INTEGER |
| artist_raw | TEXT |
| track_id | artist_raw |
|---|---|
| 1 | The Velvet Owls |
| 2 | velvet owls |
| 3 | Mira Sen |
| 4 | MIRA SEN |
| 4 | Mira Sen |
| 5 | Theo Park |
| 6 | the lanterns |
| 7 | Lanterns |
| artist_key | tracks |
|---|---|
| lanterns | 2 |
| mira sen | 2 |
| velvet owls | 2 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Category Breadcrumbs for Leaf Nodes · Hosts Rated Above Their City Average ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.