Monthly Bookings Growth

Start Timer

0:00:00

Upvote
4
Downvote
Save question
View comments

Rippling stores every booking it receives in one table. For each calendar month, we want to know how many bookings came in, the running total up to and including that month, and how that monthly count changed compared to the previous month.

Write a query that returns one row per month with the booking count, the cumulative sum of bookings, and the month-over-month percentage change.

bookings table

Column Type
customer_id INTEGER
booking_type VARCHAR
booking_date DATE
product VARCHAR

Output:

Column Type
booking_month VARCHAR
num_bookings INTEGER
cumulative_bookings INTEGER
pct_change FLOAT

Rules: - Each booking_month is formatted as YYYY-MM. - Include every calendar month from the earliest to the latest month with a booking, showing 0 for months with no bookings. - Rows with a NULL booking_date are excluded from the counts. - The previous month is the immediately preceding calendar month. - pct_change is ((current - previous) / previous) * 100, rounded to 2 decimal places, and is NULL for the first month and whenever the previous month has 0 bookings. - Sort the result by booking_month ascending.

.
.
.
.
.


Comments

Loading comments