Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top Providers by Region

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Top Providers by Region. Start with the requirements and the two tables on the right.

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.

Problem

Covera Health wants to monitor provider utilization across regions using patient visit data. Write a PostgreSQL query that identifies the highest-volume providers for each region and calendar month.

Requirements

  1. Join providers to patient_visits using provider_id.
  2. Consider only visits with status = 'completed' and a non-null patient_id.
  3. Calculate monthly patient volume as the number of distinct patients per provider.
  4. Rank providers independently within each region and month, returning the top three providers. Break ties by the lower provider_id.

Schema

providers
ColumnTypeDescription
provider_idPKINTEGERUnique provider identifier
provider_nameVARCHAR(100)Provider display name
regionVARCHAR(50)Covera Health service region
patient_visits
ColumnTypeDescription
visit_idPKINTEGERUnique visit identifier
provider_idINTEGERProvider associated with the visit
patient_idINTEGERPatient associated with the visit
visit_dateDATEDate on which the visit occurred
statusVARCHAR(20)Visit completion status
Tablesproviderspatient_visits
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results