Report Weekly Agent Success and Early Hangup Rates
Last updated: November 29, 2026
Quick Overview
Using a calls table with agent_id, started_at, ended_at, call_successful and disconnection_reason, write SQL that reports per agent for the last 7 days the total calls, connected calls, success rate, average duration and the share of connected calls the caller hung up on within 10 seconds.
Retell AI
November 29, 20260
0
0 solved
Using a calls table with agent_id, started_at, ended_at, call_successful and disconnection_reason, write SQL that reports per agent for the last 7 days the total calls, connected calls, success rate, average duration and the share of connected calls the caller hung up on within 10 seconds.
Retell's call analytics dashboards show customers how each agent performs, and early hangups are a strong signal of a bad greeting or high latency. The interviewer checks correct denominators, NULL handling for unanswered calls and unscored calls, and clean conditional aggregation.
What the Interviewer Expects
- Filter to the last 7 days on start time
- Use conditional aggregation for each rate
- Pick the right denominator for each metric (connected vs scored calls)
- Protect against division by zero with NULLIF
- Handle NULL ended_at and NULL call_successful explicitly
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 show the trend day by day for each agent?
- Success is judged by an LLM post-call analysis; how would you check it is reliable?
- How would you compare agents with very different call volumes fairly?
- How would you split the early hangup rate by inbound versus outbound calls?
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
calls(call_id, agent_id, started_at, ended_at, call_successful, disconnection_reason). Unanswered calls have ended_at NULL (never connected). call_successful is NULL when post-call analysis did ...
Approach
A CTE computes duration in seconds for recent calls, then one GROUP BY with CASE expressions. Success rate uses scored calls as the denominator, early hangup rate uses connected calls....