Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Start free
Find Lowest Graduate States by Student Population
00:00
5 left

Find Lowest Graduate States by Student Population

HardSQL · PostgreSQL

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
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.