What it does:
This query analyzes adherence rates based on the type of insurance coverage or benefit scheme patients are enrolled in — Premium, Medium, or Basic/Other.
SQL Breakdown:
CASE WHEN scheme_type_premium THEN 'Premium'...: Categorizes patients into one of three plan types.
COUNT(*) AS patients: Counts how many patients are in each scheme group.
COUNT(*) FILTER (WHERE adherence = 'ADHERENT') * 1.0 / COUNT(*) AS adherence_rate: Calculates the adherence rate for each group.
GROUP BY scheme_type_premium, scheme_type_medium: Groups the data according to the two boolean fields determining the scheme.
Output Summary:
Premium Plans: 17,893 patients — Highest adherence at ~41.89%
Medium Plans: 5,148 patients — Adherence at ~35.92%
Basic/Other Plans: 1,043 patients — Lowest adherence at ~31.06%
Why this matters:
This reveals a positive correlation between higher-tier insurance plans and better medication adherence. Patients with Premium plans adhere at a significantly higher rate than those with Basic coverage, suggesting that coverage level or plan benefits may impact treatment compliance.
Note: This dataset is synthetic and used strictly for educational purposes. It does not reflect real patient data.