Share of the Total
Return each symbol once with pct: the share of the table's total qty that was traded in that symbol, as a percentage rounded to 1 decimal. 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 | 15 | 191.0 |
returns
| symbol | pct |
|---|---|
| AAPL | 83.3 |
| MSFT | 16.7 |
Constraints
- 1 to 16 trades
- No share 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
- Volume Weighted PriceMedium
- Chain of CommandHard
- Daily BarsHard
- Longest Winning StreakHard
- Median SalaryHard
- Month Over MonthHard
- Moving AverageHard
- Position Over TimeHard