Healthcare Analytics Path · Mission 18 of 25Hard

Month-over-month encounter trend

Use LAG() window function for period-over-period comparison

Back to Healthcare Analytics

The Brief

Dr. Amara OkaforChief Quality Officerquality-analytics

Show me monthly encounter volume with month-over-month change as a percentage. I want to see if we're trending up or down. Also — exclude encounters from the provider with the future hire date. That data is suspect and I don't want it in the trend.

You'll practice

LAG()Date extraction% change

Tables available

fact_encountersdim_providers

Hints (3)

Each hint you reveal reduces the XP you can earn. Try the query first.

Hint 1

Aggregate monthly counts first. Then a window function that looks one row back chronologically gives you the prior month's count

Hint 2

Exclude the suspect provider with the future hire_date before aggregating, then compute MoM % from the current and lagged counts

Hint 3

`LAG(encounter_count, ___) OVER (ORDER BY ___, ___) AS prior_count` — then `ROUND(100.0 * (encounter_count - prior_count) / ___, 1) AS mom_change_pct`