PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates proficiency in SQL query formulation, including group-wise selection, joins, NULL handling, deterministic tie-breaking and ordering to identify a top-per-group student.

  • Medium
  • Point72
  • Data Manipulation (SQL/Python)
  • Data Scientist

Write SQL for top student per department

Company: Point72

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

Schema: Departments(dept_id PK, dept_name) Students(student_id PK, student_name, dept_id FK nullable, gpa numeric(3,2) nullable, enrolled_at date) Sample data: Departments +---------+-----------+ | dept_id | dept_name | +---------+-----------+ | 1 | CS | | 2 | Math | | 3 | Physics | | 4 | History | +---------+-----------+ Students +------------+--------------+---------+------+------------+ | student_id | student_name | dept_id | gpa | enrolled_at| +------------+--------------+---------+------+------------+ | 101 | Alice | 1 | 3.90 | 2022-09-01 | | 102 | Bob | 1 | 3.90 | 2023-01-15 | | 103 | Cara | 2 | 3.85 | 2021-09-01 | | 104 | Dan | 2 | NULL | 2024-02-01 | | 105 | Eve | NULL | 3.70 | 2023-09-01 | | 106 | Frank | 3 | 3.90 | 2020-09-01 | +------------+--------------+---------+------+------------+ Write a single SQL query to list, for every department (including those with no students), the department name and the top student by GPA; break GPA ties by earliest enrolled_at, then by smallest student_id. If a department has no students with non-NULL GPA, return one row with student fields NULL. Output columns: dept_id, dept_name, student_id, student_name, gpa, enrolled_at. Show the expected result for the sample data.

Quick Answer: This question evaluates proficiency in SQL query formulation, including group-wise selection, joins, NULL handling, deterministic tie-breaking and ordering to identify a top-per-group student.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Build the auction status table - Point72 (hard)
  • Convert integer dates to quarters - Point72 (Medium)
  • Write SQL for recent customer activity - Point72 (Medium)
  • Convert Dates to Calendar Quarter Labels in SQL/Python - Point72 (Medium)
  • List Departments with Student Counts Including Zero - Point72 (Medium)