How would you write a SQL query to compare current month engagement against the previous month using lag/lead?
Use the provided learner and engagement event data. Include active learners only and report every month from January through May 2025, including months with no qualifying engagement.
month, engaged_learners, engagement_events, previous_month_engaged_learners, learner_change, and percent_change.NULL for the first month or when percentage change cannot be calculated.| Column | Type | Description |
|---|---|---|
| learner_idPK | INT | Unique learner identifier |
| learner_name | VARCHAR(100) | Learner display name |
| status | VARCHAR(20) | Learner account status |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique engagement event identifier |
| learner_id | INT | Learner associated with the event |
| event_date | DATE | Date on which the engagement occurred |
| event_type | VARCHAR(40) | Type of engagement activity |