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
Retention Query for AR Lenses
00:00
5 left

Retention Query for AR Lenses

MediumSQL · PostgreSQL

Problem

Write a SQL query to calculate the month-over-month retention rate of users who interacted with an AR lens on Snapchat.

Assume retention for a month means the percentage of users active in the previous month who were also active in the current month. Include only valid users and lenses identified as AR lenses.

Output

  1. One row per month with a previous month of AR lens activity
  2. Columns: month, active_users, retained_users, and retention_rate
  3. active_users is the prior month's user count, and retained_users is the count active in both months
  4. Return retention_rate as a percentage rounded to two decimals, ordered chronologically

Schema

users
ColumnTypeDescription
user_idPKINTUnique Snapchat user identifier
usernameVARCHAR(50)User handle
platformVARCHAR(20)Primary mobile platform
signup_dateDATEDate the user registered
lenses
ColumnTypeDescription
lens_idPKINTUnique lens identifier
lens_nameVARCHAR(100)Display name of the lens
lens_typeVARCHAR(30)Lens classification
is_ar_lensBOOLEANWhether the lens is an AR lens
lens_interactions
ColumnTypeDescription
interaction_idPKINTUnique interaction identifier
user_idINTUser who interacted with the lens
lens_idINTLens used during the interaction
interacted_atTIMESTAMPTimestamp of the lens interaction
session_idVARCHAR(40)Optional Snapchat session identifier
Tablesuserslenseslens_interactions
Interviewer

Your question is Retention Query for AR Lenses. 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.