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
Window Functions and Churn SQL
00:00
5 left

Window Functions and Churn SQL

MediumSQL · PostgreSQL

Problem

Explain how you would use window functions to analyze churn rate for Navi’s lending customers.

Use the provided Navi lending customer and monthly activity data. Return one row per activity month, including customers who were active in the previous observed month as the churn denominator.

Output

  1. Columns: activity_month, prior_active_customers, churned_customers, churn_rate_percent
  2. Churn rate is churned customers divided by prior active customers, expressed as a percentage
  3. Sort by activity_month ascending

Schema

lending_customers
ColumnTypeDescription
customer_idPKINTUnique Navi lending customer identifier
customer_nameVARCHAR(100)Customer name
customer_segmentVARCHAR(30)Customer lending segment
customer_monthly_activity
ColumnTypeDescription
activity_idPKINTUnique monthly activity record identifier
customer_idINTReferences lending_customers.customer_id
activity_monthDATEFirst day of the activity month
is_activeBOOLEANWhether the customer was active during the month
Tableslending_customerscustomer_monthly_activity
Interviewer

Your question is Window Functions and Churn SQL. Start with the requirements and the two 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.