Return each store's `store_id` and `total_units` (sum of `units`). Order by `total_units` DESC, then `store_id`.
| Column | Type |
|---|---|
| sale_id | INTEGER |
| store_id | INTEGER |
| units | INTEGER |
| sale_id | store_id | units |
|---|---|---|
| 1 | 101 | 5 |
| 2 | 102 | 3 |
| 3 | 101 | 2 |
| 4 | 103 | 10 |
| 5 | 102 | 4 |
| store_id | total_units |
|---|---|
| 103 | 10 |
| 101 | 7 |
| 102 | 7 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Sign-in Failure Rate by Tenant Domain · Users Who Never Posted ›
{{ 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.