Skip to main content
All Questions

Duolingo Leaderboards

Hard
Unlock detailed company stats for this questionUpgrade

Duolingo is a platform that allows users to learn various languages through bite-sized lessons. Learners can complete multiple lessons in a day and track their progress in their desired language.

You're given three tables: user, lesson, and lessons_completed:

user:

user_idusername
integerstring

lesson:

lesson_idlanguage
integerstring

lessons_completed:

lesson_iduser_idcompleted_date
integerintegerdate

Write a SQL query that returns a table with the top 3 learners with the highest total lessons completed from 24 Sep 2023 to 30 Sep 2023 for each language. Your output should contain: username, language, total_lessons, rank.

Note: If two or more learners have the same number of lessons completed and are within the top 3, include them all without skipping any rank positions for subsequent learners. For example, if three learners are tied for 1st place in a language, the next learner should still be ranked as 2nd, not 4th.

Related courses

Course

Data Analyst Interview Prep

Ace your data analyst interviews—whether you're targeting product, marketing, or business analyst roles. Tackle real take-home case studies, sharpen your technical and dashboarding skills, and get strategies from interviewers at top tech companies and startups.

Course

Data Science Interview Prep

Land your dream data science role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Practice statistics, experimentation, coding, SQL, machine learning, behavioral interviews, and more.