Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Top Agents by Recovery Rate SQL
00:00
5 left

Top Agents by Recovery Rate SQL

MediumSQL · PostgreSQL

Problem

Paytm Operations needs to identify the most effective collection agents based on recovery performance. Assume the query runs on 2026-08-29, so the last calendar month is July 2026.

Write a PostgreSQL query to return the top 5 agents by collection recovery rate for cases assigned during July 2026.

Requirements

  1. Calculate recovery rate as successful July collections divided by the total assigned amount for July cases, multiplied by 100.
  2. Include agents with assigned July cases but no successful collections, while excluding agents with no assigned amount.
  3. Consider only payments with payment_status = 'SUCCESS' and a July 2026 payment date.
  4. Return the agent name, total assigned amount, total recovered amount, and recovery rate, ordered by recovery rate descending, then recovered amount descending, and agent ID ascending for deterministic ties.

Schema

agents
ColumnTypeDescription
agent_idPKINTUnique collection agent identifier
agent_nameVARCHAR(100)Collection agent's name
collection_cases
ColumnTypeDescription
case_idPKINTUnique collection case identifier
agent_idINTAgent assigned to the case
assigned_dateDATEDate the case was assigned
assigned_amountNUMERIC(12,2)Amount assigned for recovery
recovery_payments
ColumnTypeDescription
payment_idPKINTUnique payment identifier
case_idINTCollection case associated with the payment
payment_dateDATEDate the payment was received
payment_amountNUMERIC(12,2)Amount received in the payment
payment_statusVARCHAR(20)Payment processing status
payment_methodVARCHAR(30)Payment channel used
Tablesagentscollection_casesrecovery_payments
Interviewer

Your question is Top Agents by Recovery Rate SQL. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.