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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
Diagnosing Engagement Declines
00:00
5 left

Diagnosing Engagement Declines

MediumSQL · PostgreSQL

Problem

How would you approach analyzing a decline in user engagement for a specific lending product?

Use the provided tables to produce monthly engagement metrics for Trepp CRE Lending Analytics from January through April 2024.

Output

  1. One row per month, with engagement_month, active_users, engagement_events, events_per_active_user, active_users_pct_change, and engagement_events_pct_change
  2. Include the first month with NULL prior-month percentage changes
  3. Order by engagement_month ascending

Output details

  • Count distinct users for active_users and count every qualifying event for engagement_events.
  • Round events_per_active_user and both percentage-change columns to two decimal places.
  • Calculate percentage changes relative to the previous month and multiply them by 100.
  • Return NULL when a denominator is zero, including zero active users or zero prior-month values.
  • Return only months containing qualifying events; do not add rows for months without events.
  • Represent engagement_month as the first calendar day of each month.

Schema

lending_products
ColumnTypeDescription
product_idPKINTUnique lending product identifier
product_nameVARCHAR(120)Name of the lending product
product_statusVARCHAR(30)Current product status
users
ColumnTypeDescription
user_idPKINTUnique user identifier
user_nameVARCHAR(120)User display name
segmentVARCHAR(50)User business segment
engagement_events
ColumnTypeDescription
event_idPKINTUnique engagement event identifier
user_idINTUser who generated the event
product_idINTProduct associated with the event
event_dateDATEDate of the engagement event
event_typeVARCHAR(50)Type of engagement activity
Tablesengagement_eventslending_productsusers
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

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.