Find Reps Below Call Plan Attainment for the Quarter
Last updated: November 29, 2026
Quick Overview
Given a call plan table with planned calls per rep and HCP for each quarter and a calls table of logged calls, return reps whose attainment this quarter is below 80 percent, crediting at most the planned number of calls per HCP.
Veeva Systems
November 29, 20260
0
0 solved
Given a call plan table with planned calls per rep and HCP for each quarter and a calls table of logged calls, return reps whose attainment this quarter is below 80 percent, crediting at most the planned number of calls per HCP.
Commercial analytics built on CRM data constantly measures call plan attainment for field teams. This screen checks join choice (planned HCPs with zero calls must still count), status and date filtering, and the capping rule that stops extra calls on one doctor from hiding missed targets.
What the Interviewer Expects
- Starts from the plan and LEFT JOINs actual calls so zero-call HCPs count
- Filters to submitted calls in the quarter's date range
- Caps credited calls per HCP at the planned number
- Aggregates to the rep level and filters with HAVING
- Avoids integer division
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you report attainment by week to show trend within the quarter?
- A rep took over a territory mid-quarter; how would you prorate the plan?
- How would you include calls on HCPs that were not in the plan as a separate metric?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
call_plan(rep_id, hcp_id, quarter, planned_calls) and calls(call_id, rep_id, hcp_id, call_date, status). Only status = 'submitted' calls count (saved drafts or planned calls do not). Attainment ...
Approach
- CTE
planfor the quarter's targets. 2. CTEdonecounting submitted calls in the date range per rep and HCP. 3. LEFT JOIN plan to done, treat missing as 0, cap with LEAST. 4. Group by rep, compu...