Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Compare Current vs Historical Customer Behavior
00:00
5 left

Compare Current vs Historical Customer Behavior

HardSQL · PostgreSQL

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
Interviewer

Your question is Compare Current vs Historical Customer Behavior. Start with the requirements and the one table 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.