Average per Symbol
Return each symbol once with avg_price, the average price of its trades rounded to 2 decimals. Rows may come in any order.
Example 1
trades
| id | symbol | qty | price |
|---|---|---|---|
| 1 | AAPL | 10 | 190.5 |
| 2 | MSFT | 5 | 410.0 |
| 3 | AAPL | 7 | 191.0 |
| 4 | AAPL | 1 | 193.0 |
returns
| symbol | avg_price |
|---|---|
| AAPL | 191.5 |
| MSFT | 410.0 |
Constraints
- Up to 16 trades
- No average is a close call for the rounding
Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.
More SQL problems
- Biggest SpenderEasy
- Bought and SoldEasy
- Busy SymbolsEasy
- Buyers per ProductEasy
- Customers Without OrdersEasy
- Low and HighEasy
- Net PositionEasy
- Orders With NamesEasy