Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Active Unfilled Prescriptions Query
00:00
5 left

Active Unfilled Prescriptions Query

EasySQL · PostgreSQL

Problem

Write a MySQL query to retrieve all active prescriptions for a patient at Gifthealth that have not yet been filled.

Use the provided schema and assume the target patient_id is 101. Treat any matching row in prescription_fills as evidence that a prescription has been filled.

Output

  1. Return one row per qualifying prescription with prescription_id, patient_id, medication_name, and prescribed_date.
  2. Include only active, unfilled prescriptions for patient 101.
  3. Order by prescribed_date ascending, then prescription_id ascending.

Schema

prescriptions
ColumnTypeDescription
prescription_idPKINTUnique prescription identifier
patient_idINTGifthealth patient identifier
prescription_statusVARCHAR(20)Current prescription status
medication_nameVARCHAR(120)Name of the prescribed medication
prescribed_dateDATEDate the prescription was issued
quantityINTQuantity prescribed
expires_onDATEPrescription expiration date
prescription_fills
ColumnTypeDescription
fill_idPKINTUnique fill record identifier
prescription_idINTPrescription associated with the fill
filled_atTIMESTAMPTimestamp when the prescription was filled
fill_statusVARCHAR(20)Status of the fill transaction
pharmacy_nameVARCHAR(120)Pharmacy that processed the fill
Tablesprescriptionsprescription_fills
Interviewer

Your question is Active Unfilled Prescriptions Query. Start with the requirements and the two tables in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.