Provider Analytics Path · Mission 13 of 25Medium

Readmission rate by insurance type

Use CASE WHEN for rate calculation, LOWER() for normalization, and multi-table JOINs

Back to Provider Analytics

The Brief

Dr. Amara OkaforChief Quality Officerquality-analytics

Calculate the 30-day readmission rate by insurance type. Use the readmission_flag in quality metrics. Normalize insurance type so 'Medicare' and 'medicare' are grouped together. Show insurance type, total encounters with a readmission metric, readmissions, and readmission rate as a percentage rounded to 1 decimal.

You'll practice

CASELOWER()Percentages

Tables & columns available

fact_quality_metricsfact7 columns
ColumnTypeKey
metric_idINTPK
encounter_idINTFK → fact_encounters
patient_idINTFK → dim_patients
metric_typeTEXT
metric_valueREAL
measurement_dateTEXT
reported_byTEXT
fact_encountersfact10 columns
ColumnTypeKey
encounter_idINTPK
patient_idINTFK → dim_patients
provider_idINTFK → dim_providers
department_idINTFK → dim_departments
admit_dateTEXT
discharge_dateTEXT
diagnosis_codeTEXT
diagnosis_descriptionTEXT
encounter_typeTEXT
discharge_dispositionTEXT
dim_patientsdim9 columns
ColumnTypeKey
patient_idINTPK
first_nameTEXT
last_nameTEXT
date_of_birthTEXT
genderTEXT
insurance_typeTEXT
zip_codeTEXT
primary_languageTEXT
is_deceasedINT

Hints (3)

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

Hint 1

Three tables chain together: the metric links to the encounter, which links to the patient. Filter the metric_type upfront

Hint 2

Compute two quantities per group — totals and readmissions — and divide. Normalize the grouping key so casing doesn't split rows

Hint 3

`SELECT LOWER(p.insurance_type) AS insurance_type, COUNT(*) AS total_encounters, SUM(CASE WHEN qm.metric_value = 1 THEN ___ ELSE ___ END) AS readmissions, ROUND(100.0 * SUM(CASE WHEN qm.metric_value = 1 THEN 1 ELSE 0 END) / ___, 1) AS readmission_rate ... GROUP BY LOWER(___)`