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
SQL for Second Highest Marks
00:00
5 left

SQL for Second Highest Marks

EasySQL · PostgreSQL

Problem

Yum! Brands uses Yum Academy assessments to monitor employee readiness across its restaurant brands. Write a PostgreSQL query to identify the student or students with the second-highest marks in the Restaurant Operations Assessment.

Requirements

  1. Join students to their assessment scores and the assessment definition.
  2. Rank distinct non-null marks from highest to lowest using a window function.
  3. Return every student whose marks are the second-highest distinct score, ordered by student name.

Schema

students
ColumnTypeDescription
student_idPKINTUnique student identifier
student_nameVARCHAR(100)Student's full name
brandVARCHAR(50)Yum! Brands restaurant brand
assessments
ColumnTypeDescription
assessment_idPKINTUnique assessment identifier
assessment_nameVARCHAR(150)Assessment title
assessment_scores
ColumnTypeDescription
score_idPKINTUnique score record
student_idINTStudent receiving the score
assessment_idINTAssessment being scored
marksINTAssessment marks from 0 to 100
Tablesstudentsassessmentsassessment_scores
Interviewer

Your question is SQL for Second Highest Marks. Start with the requirements and the three 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.