Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL for Student Analytics

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

Your question is SQL for Student Analytics. 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

Syapse's Precision Medicine Platform needs a state-level education summary to identify regions with the fewest graduates while prioritizing regions with the largest student populations. Write a PostgreSQL query that uses the student, graduate, and education tables.

Requirements

  1. Count distinct students and distinct graduates for each student state.
  2. Include students with no graduate or education record, treating missing graduate records as zero graduates.
  3. Identify every state tied for the minimum graduate count, then return the three states with the most students among that group.
  4. Sort by total students descending, then state ascending to make ties deterministic.

Schema

student
ColumnTypeDescription
student_idPKINTUnique student identifier
student_nameVARCHAR(100)Student's full name
stateVARCHAR(2)Two-letter state code
graduate
ColumnTypeDescription
graduate_idPKINTUnique graduation record identifier
student_idINTStudent associated with the graduation record
graduation_yearINTYear of graduation
education
ColumnTypeDescription
education_idPKINTUnique education record identifier
student_idINTStudent associated with the education record
degreeVARCHAR(100)Degree or educational program
institution_nameVARCHAR(150)Educational institution name
Tablesstudentgraduateeducation
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results