Top-Day Revenue Gap Between Two Branches
Problem
Table: `daily_sales`
| Column Name | Type |
|---|---|
| branch | varchar |
| sale_date | date |
| revenue | int |
Each row is the total revenue a bookstore branch earned on one day.
Find the absolute difference between the single best day at the `Riverside` branch and the single best day at the `Hilltop` branch. Return one row with that value aliased as `revenue_gap`.
Tables
Example rows — the live problem includes the full dataset.
daily_sales
| branch | sale_date | revenue |
|---|---|---|
| Riverside | 2024-04-01 | 1200 |
| Riverside | 2024-04-02 | 3100 |
| Riverside | 2024-04-03 | 2500 |
Expected output
Your answer should return 1 row with the columns revenue_gap.
Starter code (SQL)
SELECT *
FROM daily_sales;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock