Bought but Never Sold
Return each symbol that has at least one buy and no sell at all, once. Rows may come in any order.
Example 1
trades
| id | symbol | side | qty | price |
|---|---|---|---|---|
| 1 | AAPL | buy | 10 | 190.5 |
| 2 | AAPL | sell | 4 | 191.0 |
| 3 | MSFT | buy | 5 | 410.0 |
| 4 | MSFT | buy | 1 | 409.0 |
| 5 | KO | sell | 2 | 61.0 |
returns
| symbol |
|---|
| MSFT |
Constraints
- Up to 16 trades
sideisbuyorsell
Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.
More SQL problems
- Change From the Day BeforeMedium
- First OrderMedium
- Latest PriceMedium
- More Than the ManagerMedium
- Open PositionsMedium
- Rank in the DepartmentMedium
- Revenue per CityMedium
- Running BalanceMedium