Write a SQL query to compare pre- and post-launch engagement using window functions and date-based grouping for Dow Jones.
Use the supplied product, user, and engagement event data. Consider the two calendar months before launch as the pre-launch phase and the two calendar months after launch as the post-launch phase. Exclude the launch month and products without valid engagement events.
Output
- One row per product and phase, with
product_name, phase, avg_monthly_events, avg_monthly_active_users, events_per_active_user, and change_from_previous_phase.
- Include
pre before post, and sort by product name, then phase order.
change_from_previous_phase is NULL for pre-launch and otherwise compares average monthly events with the preceding phase.