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
Fastest Mastery Segment SQL
00:00
5 left

Fastest Mastery Segment SQL

HardSQL · PostgreSQL

Problem

Khan Academy wants to identify learners who reach skill mastery most efficiently. Write a PostgreSQL query that finds the fastest 5% of learners based on the elapsed time between their first practice attempt and their first recorded mastery.

Requirements

  1. Calculate each learner's elapsed time to mastery for every skill with a qualifying mastery event.
  2. Summarize each learner using their average hours to mastery and count of mastered skills.
  3. Exclude learners without a qualifying mastery event. Treat mastery as an event where mastery_level = 'mastered'.
  4. Rank eligible learners by average mastery time in ascending order and return the fastest 5%. Round average hours to two decimal places.
  5. Return learner_id, learner_name, mastered_skills, avg_hours_to_mastery, rank_position, and eligible_learner_count.

Schema

learners
ColumnTypeDescription
learner_idPKINTUnique Khan Academy learner identifier
learner_nameVARCHAR(100)Display name of the learner
practice_attempts
ColumnTypeDescription
attempt_idPKINTUnique practice attempt identifier
learner_idINTLearner who made the attempt
skill_nameVARCHAR(100)Khan Academy skill practiced
attempted_atTIMESTAMPTimestamp when the practice attempt occurred
skill_mastery_events
ColumnTypeDescription
mastery_event_idPKINTUnique mastery event identifier
learner_idINTLearner associated with the mastery event
skill_nameVARCHAR(100)Khan Academy skill whose mastery status changed
mastery_levelVARCHAR(30)Recorded status, such as in_progress or mastered
mastered_atTIMESTAMPTimestamp when the status was recorded
Tableslearnerspractice_attemptsskill_mastery_events
Interviewer

Your question is Fastest Mastery Segment SQL. 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.