Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
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 feedbackCoaching1:1 coaching with people at your target companiesSuccess 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 Procedures by State
00:00
5 left

Top Procedures by State

MediumSQL · PostgreSQL

Problem

Business Context

Gainwell Technologies needs a quarterly view of medical procedure utilization across state Medicaid programs. Analysts must identify the procedures most frequently billed in each provider state.

Task

Assume the reporting date is August 29, 2026, so the last completed calendar quarter is April 1 through June 30, 2026. Write a PostgreSQL query that returns the top three billed procedures per state.

Requirements

  1. Join claims to providers, claim lines, and medical procedures.
  2. Include only claim lines with billing_status = 'BILLED' during the last completed quarter.
  3. Count billed claim lines for each state and procedure.
  4. Rank procedures independently within each state and return ranks 1 through 3.
  5. Sort by state, billed count descending, and procedure code for deterministic tie handling.

Schema

providers
ColumnTypeDescription
provider_idPKINTUnique provider identifier
provider_nameVARCHAR(150)Provider or organization name
state_codeVARCHAR(2)Two-character provider state code
taxonomyVARCHAR(100)Provider specialty classification
claims
ColumnTypeDescription
claim_idPKINTUnique claim identifier
claim_numberVARCHAR(30)External claim reference
provider_idINTReferences providers.provider_id
member_idVARCHAR(30)Medicaid member identifier
service_dateDATEDate services were provided
claim_statusVARCHAR(20)Overall claim processing status
claim_lines
ColumnTypeDescription
claim_line_idPKINTUnique claim line identifier
claim_idINTReferences claims.claim_id
procedure_idINTReferences medical_procedures.procedure_id
billing_statusVARCHAR(20)Line billing disposition
unitsINTNumber of units billed
medical_procedures
ColumnTypeDescription
procedure_idPKINTUnique procedure identifier
procedure_codeVARCHAR(10)Procedure billing code
procedure_nameVARCHAR(150)Procedure description
Tablesprovidersclaimsclaim_linesmedical_procedures
Interviewer

Your question is Top Procedures by State. Start with the requirements and the four 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.