Share of Perfect Lessons per Course Last Week
Last updated: November 29, 2026
Quick Overview
From a lesson_completions table with course_id, mistakes and completed_at, compute for each course the number of lessons completed in a given week and the share completed with zero mistakes, keeping only courses with at least 1,000 completions.
Duolingo
November 29, 20260
0
0 solved
From a lesson_completions table with course_id, mistakes and completed_at, compute for each course the number of lessons completed in a given week and the share completed with zero mistakes, keeping only courses with at least 1,000 completions.
Duolingo's learning and content teams watch how hard each course feels, and the share of mistake-free lessons is a simple proxy. A technical screen uses this to check clean aggregation, date filtering with half-open ranges, and awareness that small courses produce noisy rates.
What the Interviewer Expects
- Filters dates with a half-open range so the boundary day is not double counted
- Computes the share with a CASE inside AVG or a SUM ratio, avoiding integer division
- Uses HAVING for the minimum volume filter
- Orders the output meaningfully
- Mentions that a high perfect share could mean content is too easy, not just learners are strong
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you compare the same unit across courses with different learner mixes?
- How would you exclude practice and review lessons from new-content lessons?
- How would you turn this into a weekly trend per course?
- What does a sudden jump in perfect share after a release tell you?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
One row per completed lesson: course_id, mistakes (non-null integer), completed_at (timestamp, UTC). The week is 2026-11-01 inclusive to 2026-11-08 exclusive. Abandoned lessons are not in the ta...
Approach
Filter to the week, group by course, count rows, and average an indicator for mistakes = 0. Apply the volume floor with HAVING since it depends on the aggregate. Using AVG of a 0/1 indicator is th...