Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top Diagnosis Codes

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

Your question is Top Diagnosis Codes. Start with the requirements and the one table 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

Providence's clinical data warehouse contains diagnosis records associated with patient encounters. Write a PostgreSQL query to identify the most frequently recorded diagnosis codes.

Requirements

  1. Count non-null diagnosis records for each diagnosis_code.
  2. Return the 10 most frequent codes, ordered by frequency descending. Break ties alphabetically by diagnosis code.

Schema

clinical_diagnoses
ColumnTypeDescription
diagnosis_idPKINTUnique diagnosis record identifier
encounter_idINTProvidence encounter identifier
diagnosis_codeVARCHAR(10)ICD diagnosis code
recorded_dateDATEDate the diagnosis was recorded
Tablesclinical_diagnoses
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results