Tell me how you would approach writing SQL for a task that requires interpreting an ERD and producing results from subqueries with calculations and conditions under tight time constraints.
For this exercise, use the provided property, booking, and payment tables. Produce the requested result while making assumptions explicit and handling missing payment records.
Output
- One row per qualifying property and booking month.
- Columns:
property_name, booking_month, completed_bookings, net_revenue, average_booking_value, previous_month_revenue, revenue_change_pct, and revenue_rank.
- Include only months with at least two positive-value completed bookings.
- Order by booking month ascending, revenue rank ascending, and property name ascending.