fulfillment_orders has one row per sale (category, item, revenue); the same item can appear on several rows. First total the revenue of each item within its category, then return the highest-grossing item of each category; if several items tie for the top total, return all of them. Output columns: category, item, revenue (the item's total, rounded to 2 decimals). Order by category, then item.
| Column | Type |
|---|---|
| category | TEXT |
| item | TEXT |
| revenue | REAL |
| category | item | revenue |
|---|---|---|
| Electronics | Phone | 500 |
| Electronics | Tablet | 300 |
| Home | Chair | 250 |
| Home | Lamp | 250 |
| Home | Desk | 400 |
| category | item | revenue |
|---|---|---|
| Electronics | Phone | 500 |
| Home | Desk | 400 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
{{ 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.