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 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.
| Column | Type | Description |
|---|---|---|
| booking_idPK | INT | Primary key for each booking |
| customer_id | INT | Customer identifier |
| customer_name | VARCHAR(100) | Customer name |
| booking_date | DATE | Date the booking was made |
| booking_status | VARCHAR(20) | Booking status such as confirmed or cancelled |
| booking_value | NUMERIC(10,2) | Booking value in AUD |