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
Rank Customer Segments by Revenue
00:00
5 left

Rank Customer Segments by Revenue

HardSQL · PostgreSQL

Problem

You are given signup, account, and payment data from a B2B SaaS product. Write a SQL query to identify the highest-performing customer segments based on both revenue and signup-to-paid conversion. Treat a customer as converted if they have at least one successful payment within 30 days of signup. Return each segment's total customers, converted customers, conversion rate, total revenue from successful payments, and a rank ordered by highest revenue.

Use the segmentation dimensions already stored on the customer record, and only include segments with at least 2 customers.

Schema

rippling_customers
ColumnTypeDescription
customer_idPKINTUnique customer identifier
company_nameVARCHAR(100)Customer company name
company_size_segmentVARCHAR(20)Segment based on employee count
regionVARCHAR(20)Customer geographic region
signup_dateDATEDate the customer signed up
rippling_accounts
ColumnTypeDescription
account_idPKINTUnique billing account identifier
customer_idINTCustomer associated with the account
plan_nameVARCHAR(30)Subscribed Rippling plan
account_statusVARCHAR(20)Current billing account status
rippling_payments
ColumnTypeDescription
payment_idPKINTUnique payment identifier
account_idINTBilling account tied to the payment
payment_dateDATEDate the payment was processed
amount_usdDECIMAL(10,2)Payment amount in USD
payment_statusVARCHAR(20)Payment outcome
Tablesrippling_customersrippling_accountsrippling_payments
Interviewer

Your question is Rank Customer Segments by Revenue. 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.