Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Track Monthly Customer Activity Changes

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Track Monthly Customer Activity Changes. Start with the requirements and the one table on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

You are given customer booking activity and asked to track how behavior changes over time. Write a PostgreSQL query that returns each customer’s monthly booking count, the previous month’s booking count, the month-over-month change, and the cumulative bookings to date for that customer. Include only months where the customer had at least one booking.

Schema

customer_bookings
ColumnTypeDescription
booking_idPKINTPrimary key for each booking
customer_idINTCustomer identifier
customer_nameVARCHAR(100)Customer name
booking_dateDATEDate the booking was made
booking_statusVARCHAR(20)Booking status such as confirmed or cancelled
booking_valueNUMERIC(10,2)Booking value in AUD
Tablescustomer_bookings
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results