Write a SQL query to analyze user engagement by feature and date, including aggregations and trend breakdowns.
Use the provided users, features, and engagement_events tables. Include engagement dates with recorded events and compare each feature's activity with its previous available date.
Output
- One row per feature and engagement date
- Columns:
feature_name, engagement_date, total_events, unique_users, average_duration_seconds, previous_day_events, event_change, and trend
- Include all feature-date combinations with valid users and features, ordered by
feature_name, then engagement_date
- Label trends as
Up, Down, Stable, or No prior date