Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Rank Top Failing Consent Workflows

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

Your question is Rank Top Failing Consent Workflows. 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

Wakemed Operations uses MyChart consent workflows for proxy access, releases, research participation, and interpreter-supported communications. Write a PostgreSQL query to identify the five workflows with the highest failure rates for selected patient segments.

Requirements

  1. Include only attempts from the pediatric_proxy, limited_english, and older_adult segments between 2025-01-01 inclusive and 2025-04-01 exclusive.
  2. Calculate total attempts, failed attempts, and failure rate percentage for each workflow.
  3. Exclude workflows with fewer than two qualifying attempts.
  4. Return the top five workflows, ordered by failure rate descending, failed attempts descending, and workflow name ascending to break ties.

Schema

consent_workflows
ColumnTypeDescription
workflow_idPKINTUnique consent workflow identifier
workflow_nameVARCHAR(150)Display name of the consent workflow
patients
ColumnTypeDescription
patient_idPKINTUnique patient identifier
user_segmentVARCHAR(50)Operational segment assigned to the patient
consent_attempts
ColumnTypeDescription
attempt_idPKINTUnique consent attempt identifier
workflow_idINTWorkflow used for the attempt
patient_idINTPatient associated with the attempt
statusVARCHAR(20)Attempt outcome, such as completed or failed
attempted_atTIMESTAMPTimestamp when the consent attempt occurred
Tablesconsent_workflowspatientsconsent_attempts
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results