Top results with order by and limit
PremiumIn E1, use QUERY to show the Rep and Amount of the two biggest sales, biggest first.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Region | Rep | Amount | |||
| 2 | North | Ann | 120 | |||
| 3 | South | Bo | 80 | |||
| 4 | North | Cy | 200 | |||
| 5 | West | Di | 50 | |||
| 6 | South | Ed | 150 | |||
| 7 | ||||||
| 8 |
Premium lesson
Unlock QUERY and every other lesson
This is a premium lesson. Premium lets you solve it and every other lesson, take the timed mock tests, and earn certificates you can share on LinkedIn.
Next with premium:ARRAYFORMULASPLIT and JOIN
Need help?
Why this works
order by C desc sorts the rows by amount, biggest first, and limit 2 keeps the first two. Without desc, order by sorts from smallest to biggest.
Common mistake: Putting limit before order by. QUERY wants its clauses in order: select, where, group by, order by, limit.
The answer
- E1
=QUERY(1A1:C6,2"select B, C order by C desc limit 2")
In plain words: From 1the table in A1:C6, 2show the two biggest sales, biggest first.