Cheapest First
Return the id and price of every trade, the cheapest first. Trades at the same price go in order of id, smallest first.
Example 1
trades
| id | symbol | qty | price |
|---|---|---|---|
| 3 | AAPL | 10 | 20.0 |
| 1 | MSFT | 5 | 35.5 |
| 2 | AAPL | 7 | 20.0 |
| 4 | KO | 1 | 9.75 |
returns
| id | price |
|---|---|
| 4 | 9.75 |
| 2 | 20.0 |
| 3 | 20.0 |
| 1 | 35.5 |
Constraints
- Up to 12 trades
- Ids are unique
Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.
More SQL problems
- Each Symbol OnceBeginner
- How Many SellsBeginner
- No ManagerBeginner
- One SymbolBeginner
- One of SeveralBeginner
- Only the Big OnesBeginner
- Starts With ABeginner
- Three LargestBeginner