Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Track Monthly Customer Activity Changes
00:00
5 left

Track Monthly Customer Activity Changes

MediumSQL · PostgreSQL

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
Interviewer

Your question is Track Monthly Customer Activity Changes. Start with the requirements and the one table in the Question tab.

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.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.