Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Join and Group By Practice

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

Your question is SQL Join and Group By Practice. Start with the requirements and the four 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

The College Board needs a monthly view of SAT performance across test centers. Write a PostgreSQL query that combines registration, student, test center, and score data to identify centers with at least two scored, confirmed registrations per month.

Requirements

  1. Use INNER JOIN operations to combine the related tables.
  2. Consider only confirmed registrations from 2025 and use the latest score report for each registration.
  3. Group results by test center and registration month, returning registered count, scored count, and average total score.
  4. Use HAVING to retain groups with at least two scored registrations.
  5. Use LAG to show the previous month's average score and the change from that month.
  6. Briefly explain when a join is preferable to a subquery, and mention how a subquery or CTE could isolate the latest score report.

Schema

students
ColumnTypeDescription
student_idPKINTStudent identifier
student_nameVARCHAR(100)Student name
school_nameVARCHAR(150)Student school
grade_levelINTCurrent grade level
registrations
ColumnTypeDescription
registration_idPKINTRegistration identifier
student_idINTRegistered student
center_idINTSelected test center
registered_atDATERegistration date
statusVARCHAR(20)Registration status
test_centers
ColumnTypeDescription
center_idPKINTTest center identifier
center_nameVARCHAR(120)Test center name
regionVARCHAR(50)Geographic region
score_reports
ColumnTypeDescription
report_idPKINTScore report identifier
registration_idINTAssociated registration
report_dateDATEScore publication date
total_scoreINTCombined SAT score
Tablesstudentsregistrationstest_centersscore_reports
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results