Show each player's team-best and team-worst
The daily_revenue table stores per-day revenue. The CFO wants every day shown next to the very first and very last revenue value across the whole reporting window — a handy baseline for "today vs. the earliest / latest day" comparisons.
For each day return d, revenue, first_rev, last_rev — where first_rev is the earliest day's revenue in the set and last_rev is the latest day's. Order by d.
Gotcha: the window function that returns the "last" value defaults to a frame that ends at the current row, so without explicitly extending the frame to the end of the partition it returns the current row's value instead of the actual last one.
Expected output sample
This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables.
| d | revenue | last_rev | first_rev |
|---|---|---|---|
| 2024-01-01 | 100.00 | 135.00 | 100.00 |
| 2024-01-02 | 120.00 | 135.00 | 100.00 |
| 2024-01-03 | 110.00 | 135.00 | 100.00 |
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in