Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Compare Segment Performance Over Time

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Compare Segment Performance Over Time. Start with the requirements and the three tables on the right.

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.

Problem

Write a PostgreSQL query that compares monthly performance across active segments in an Equifax-style reporting model. Your result should show every active segment for every reporting month, including months with no applications, and calculate application volume, approvals, approval rate, revenue, and month-over-month revenue change.

Schema

ColumnTypeDescription
segment_id
segment_name
is_active
ColumnTypeDescription
application_id
segment_id
application_date
status
revenue
ColumnTypeDescription
month_start

What This Tests

  • Joining dimension and fact tables at a monthly grain
  • Using a CTE for reusable aggregated logic
  • Applying conditional aggregation with CASE
  • Handling zero-activity months correctly
  • Comparing time periods within each segment
Tablessegmentsapplicationsreporting_months
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results