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
Cohort Payment Trends SQL
00:00
5 left

Cohort Payment Trends SQL

HardSQL · PostgreSQL

Problem

Rover's Business Analytics team wants to monitor payment performance across user cohorts. Write a PostgreSQL query that summarizes the last four calendar quarters represented by payment activity for selected Rover cohorts.

Requirements

  1. Join users to payments and include only the New Sitter, Experienced Sitter, and New Pet Parent cohorts.
  2. Return one row per cohort and quarter, including payment attempts, successful payments, successful gross amount, Rover fees, net amount, and success rate.
  3. Treat only payments with status = 'succeeded' as successful financial activity. Use 0 for financial totals when no payment in a group qualifies.
  4. Order results by cohort and quarter chronologically. Derive the four-quarter range from the latest payment date in the selected cohorts.

Schema

users
ColumnTypeDescription
user_idPKINTUnique Rover user identifier
cohort_labelVARCHAR(40)Business-defined user cohort
signup_dateDATEDate the user joined Rover
payments
ColumnTypeDescription
payment_idPKINTUnique payment attempt identifier
user_idINTUser associated with the payment attempt
payment_dateDATEDate of the payment attempt
statusVARCHAR(20)Payment processing status
amountNUMERIC(10,2)Payment amount before Rover fees
rover_feeNUMERIC(10,2)Fee retained by Rover
payment_methodVARCHAR(20)Payment method used
Tablesuserspayments
Interviewer

Your question is Cohort Payment Trends 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.