Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Max CGPA by Year and Gender
00:00
5 left

Max CGPA by Year and Gender

MediumSQL · PostgreSQL

Problem

Write an SQL query to find the maximum CGPA per year, broken down by gender.

Use the student and academic record data. Treat records with a missing CGPA as unavailable.

Output

  1. One row per academic year and gender with a non-null CGPA
  2. Columns: year, gender, and max_cgpa
  3. Sort by year ascending, then gender ascending, with missing gender values last

Schema

students
ColumnTypeDescription
student_idPKINTUnique student identifier
student_nameVARCHAR(100)Student's full name
genderVARCHAR(30)Student's gender classification
academic_records
ColumnTypeDescription
record_idPKINTUnique academic record identifier
student_idINTStudent associated with the academic record
academic_yearINTAcademic year represented as a four-digit year
cgpaNUMERIC(3,2)Cumulative grade point average
Tablesstudentsacademic_records
Interviewer

Your question is Max CGPA by Year and Gender. Start with the requirements and the two tables in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.