Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Joins and Aggregations

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

Your question is SQL Joins and Aggregations. 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

Align Technology wants to review Invisalign scan activity across provider practices. Write a PostgreSQL query that summarizes qualifying scans by practice for the first quarter of 2025.

Requirements

  1. Use INNER JOIN to connect practices, patients, and Invisalign scans.
  2. Include only scans with scan_status = 'Completed' from January 1 through March 31, 2025.
  3. Return each practice name, the number of distinct patients, the number of completed scans, average scan duration, and total scan file size.
  4. Include only practices with at least two qualifying scans, ordered by scan count descending and practice name ascending.

Schema

practices
ColumnTypeDescription
practice_idPKINTUnique provider practice identifier
practice_nameVARCHAR(120)Provider practice name
regionVARCHAR(40)Practice operating region
patients
ColumnTypeDescription
patient_idPKINTUnique patient identifier
practice_idINTPractice associated with the patient
full_nameVARCHAR(120)Patient full name
scans
ColumnTypeDescription
scan_idPKINTUnique intraoral scan identifier
patient_idINTPatient associated with the scan
scan_dateDATEDate the scan was captured
scan_statusVARCHAR(20)Processing status of the scan
duration_secondsINTScan duration in seconds
file_size_mbDECIMAL(8,2)Digital scan file size in megabytes
Tablespracticespatientsscans
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results