Latest Price
prices holds closing prices: one row per symbol and day, and not every symbol has a price on every day. Return each symbol once with close: its price on the latest day it has one. Rows may come in any order.
Example 1
prices
| symbol | day | close |
|---|---|---|
| AAPL | 2026-01-05 | 190.5 |
| AAPL | 2026-01-07 | 188.0 |
| MSFT | 2026-01-06 | 410.0 |
| MSFT | 2026-01-02 | 415.25 |
returns
| symbol | close |
|---|---|
| AAPL | 188.0 |
| MSFT | 410.0 |
Constraints
- Up to 16 rows
- A symbol has at most one row per day
Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.
More SQL problems
- More Than the ManagerMedium
- Open PositionsMedium
- Rank in the DepartmentMedium
- Revenue per CityMedium
- Running BalanceMedium
- Second From the TopMedium
- Share of the TotalMedium
- Volume Weighted PriceMedium