Interview questions · CVS Health
Compute specialty spend share and top age band
This question evaluates data manipulation and aggregation skills in SQL and Pandas, including joins/unions across disjoint member tables, computation of specialty spend shares, identification of top age bands by claim counts with tie handling, year-based date filtering, and categorical recoding with monthly grouping.
You are given healthcare claims data split across member tables.
Tables
Assume the following schemas (types may be adapted to your SQL dialect):
mem1
member_idINT PRIMARY KEYage_bandVARCHAR
mem2
member_idINT PRIMARY KEYage_bandVARCHAR
claim
claim_idINT PRIMARY KEYmember_idINTspecialtyVARCHARpaid_amtDECIMAL(12,2)claim_dateDATE
risk (provided but not necessarily needed)
member_idINTrisk_scoreDECIMAL(10,4)
Assume claim.member_id joins to either mem1.member_id or mem2.member_id.
Assume claim_date is in UTC and “year = 2017” means calendar year 2017.
Part A (SQL)
For each specialty, compute:
total_paid_amt= total paid amount for that specialtypaid_share= that specialty’s share of total paid amount across all claims
Output columns: specialty, total_paid_amt, paid_share.
Part B (SQL)
Considering only claims in calendar year 2017:
- Union
mem1andmem2into a single member set. - Join members to claims.
- Compute claim counts per
age_band. - Return the age band(s) with the maximum number of claims (keep ties).
Output columns: age_band, claim_cnt.
Part C (Python / Pandas)
You are given a Pandas DataFrame df_claims with columns:
paid_amt(numeric)gender(values are'M'or'F')claim_timestamp(string or datetime-like)
Tasks:
- Recode
genderfromM/Ftomale/female. - Compute total
paid_amtfor each month in 2017, grouped bygenderand month.
Output: a DataFrame with columns like gender, month (1–12), total_paid_amt (and optionally year if you keep it).
Community answers
Nothing here yet.
Join in on CSWork →