Paths/Data Engineer/SQL & Query Craft / Query Foundations
Aggregate With Window Functions
Totals tell you where you are, comparisons tell you where you are going. Write the daily revenue query with a running total and a day-over-day comparison.
Validator
⏱ 0:00
IDLE — checks run live as you type commands; submit when done
01Requirements
live checks- File ~/warehouse/queries/revenue_by_day.sql exists○
- The query groups by day and sums the revenue○
- The query computes a running total with a window function○
- The query compares each day with the previous one○
02Walkthrough
1 of 4 revealed- 01
Write the daily totals
date_trunc cuts the timestamp to the day, so every order lands in the right bucket. sum turns the rows into revenue.
echo SELECT date_trunc('day', created_at) AS day,\nSUM(amount) AS revenue\nFROM orders\nWHERE status = 'paid'\nGROUP BY day\nORDER BY day; > ~/warehouse/queries/revenue_by_day.sql - 3 locked · each failed submit reveals one
03Stuck?
0 of 3 revealedTake a hint without losing the lab — each one points at the thing to look at, not at the answer.
04AI Tutor
guides, never solvesTell me what you're stuck on — I'll nudge, not solve. Which requirement are you looking at?
04Notebook
saved locally in this browserlearner@lab — ubuntu:24.04
Session is disposable
↑/↓ recalls commands · Ctrl+Enter submits · type help for the command list