Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top-Decile Utilization SQL

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

Your question is Top-Decile Utilization SQL. 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

Extract top-decile utilizing members using CTEs and ranking window functions.

Use the members and utilization_events tables. Calculate utilization from event units, include members with no events, and assign the highest-utilization decile deterministically.

Output

  1. One row per member in the highest utilization decile.
  2. Columns: member_id, member_name, utilization_events, total_utilization_units, utilization_rank, and utilization_decile.
  3. Order by total_utilization_units descending, then member_id ascending.

Schema

members
ColumnTypeDescription
member_idPKINTUnique member identifier
member_nameVARCHAR(100)Member display name
utilization_events
ColumnTypeDescription
event_idPKINTUnique utilization event identifier
member_idINTMember associated with the event
service_dateDATEDate of the utilization event
utilization_unitsINTUnits attributed to the event
Tablesmembersutilization_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results