Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Compare Current vs Historical Customer Behavior

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

Your question is Compare Current vs Historical Customer Behavior. Start with the requirements and the one table 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 each customer's latest active month on ACME House with their own prior 3-month baseline. Use only completed orders, aggregate behavior by calendar month, and return customers only when a full 3-month history exists.

Schema

ColumnTypeDescription
order_idINT
customer_idINT
order_dateDATE
order_statusVARCHAR(20)
order_amountNUMERIC(10,2)
channelVARCHAR(20)
Tablesacme_house_orders
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results