Total per Symbol
Return each symbol once with total, the sum of qty over its trades. 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 |
returns
| symbol | total |
|---|---|
| AAPL | 17 |
| MSFT | 5 |
Constraints
- Up to 16 trades
Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.
More SQL problems
- Totals by MonthEasy
- Above the AverageMedium
- Best Paid in Each DepartmentMedium
- Bought but Never SoldMedium
- Change From the Day BeforeMedium
- First OrderMedium
- Latest PriceMedium
- More Than the ManagerMedium