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
Top Lessons by Completion Rate
00:00
5 left

Top Lessons by Completion Rate

MediumSQL · PostgreSQL

Problem

How would you use SQL to identify the top 10 lessons by completion rate in the last 30 days?

Use the lesson_progress table. Treat each row as one learner's lesson assignment, and calculate completion rate as completed assignments divided by all assignments in the period.

Output

  1. One row per lesson, with lesson_name, completion_rate, and assignment_count.
  2. Include only activity from the last 30 days and exclude records without a lesson name.
  3. Sort by completion rate descending, then lesson name ascending, and return at most 10 rows.

Schema

lesson_progress
ColumnTypeDescription
progress_idPKINTUnique progress record identifier
learner_idINTLearner assigned to the lesson
lesson_nameVARCHAR(150)Name of the lesson
activity_dateDATEDate of the learner's lesson activity
completedBOOLEANWhether the learner completed the lesson
Tableslesson_progress
Interviewer

Your question is Top Lessons by Completion Rate. Start with the requirements and the one table 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.