Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Top Entities by Negative Outcome

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

Your question is SQL Top Entities by Negative Outcome. Start with the requirements and the three 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

athenahealth uses encounter and outcome data to monitor operational performance across providers. Write a PostgreSQL query to identify the providers with the highest rate of negative encounter outcomes during the last completed calendar quarter.

Treat DENIED and DELAYED outcomes as negative. The rate is negative outcomes divided by all qualifying encounters, including encounters with no recorded outcome.

Requirements

  1. Filter encounters to the last completed calendar quarter based on the current date.
  2. Calculate total encounters, negative outcomes, and the negative outcome rate for each provider.
  3. Return the top five providers, ordered by negative outcome rate descending. Break ties with total encounters descending, then provider_id ascending.
  4. Exclude providers with no qualifying encounters.

Schema

providers
ColumnTypeDescription
provider_idPKINTUnique provider identifier
provider_nameVARCHAR(100)Provider display name
encounters
ColumnTypeDescription
encounter_idPKINTUnique encounter identifier
provider_idINTProvider associated with the encounter
encounter_dateDATEDate the encounter occurred
encounter_outcomes
ColumnTypeDescription
encounter_idPKINTEncounter associated with the outcome
outcome_statusVARCHAR(20)Recorded encounter outcome status
Tablesprovidersencountersencounter_outcomes
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results