Return the three highest-revenue products in each category.
revenue break on product_id ascendingcategory, then revenue descending, then product_id ascendingproducts| revenue | category | product_id |
|---|---|---|
| 500 | books | 1 |
| 300 | books | 2 |
| 100 | books | 3 |
| 90 | toys | 4 |
| category | product_id | revenue |
|---|---|---|
| books | 1 | 500 |
| books | 2 | 300 |
| books | 3 | 100 |
| toys | 4 | 90 |
products| revenue | category | product_id |
|---|---|---|
| 10 | books | 1 |
| 40 | books | 2 |
| 30 | books | 3 |
| 20 | books | 4 |
| category | product_id | revenue |
|---|---|---|
| books | 2 | 40 |
| books | 3 | 30 |
| books | 4 | 20 |
Community-reported interview topic. Not an official company question and no affiliation is implied.
Run against the public tests, or submit to score against all of them.