Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

First Product Purchased Per Customer

Medium
MediumSQL & Data ManipulationWindow FunctionsJoinsRankingAsked 1 times

Problem

Write a PostgreSQL query to find the first product each customer purchased on the Apidel Technologies platform. Return the customer, the first order, its timestamp, and the product name. If two orders share the same earliest timestamp for a customer, use the smaller order_id as the tie-breaker.

Schema

customers
ColumnTypeDescription
customer_idINTPrimary key
customer_nameVARCHAR(100)Customer name
orders
ColumnTypeDescription
order_idINTPrimary key
customer_idINTCustomer reference
product_idINTProduct reference
purchased_atTIMESTAMPPurchase timestamp
products
ColumnTypeDescription
product_idINTPrimary key
product_nameVARCHAR(100)Product name
Practicing as: Customer Insights Analyst interview at Apidel Technologies

Hi, I'll play your Apidel Technologies interviewer for the Customer Insights Analyst role. Answer the question above like we're in the room, and I'll respond the way a real interviewer would.

Take this as a live interview session →

You are practicing as a guest. Sign up free to run your code against the sample data. Your draft stays right here.

Sign up freeI have an account
SELECT ...
FROM ...
JOIN ... ON ...
GROUP BY ...
HAVING ...
ORDER BY ... DESC;
Sign up to unlock solutions
Apidel Technologies Customer Insights Analyst Interview QuestionsTop 50 Ranking Interview Questions
Next questions
MetaSecond Most Recent Marketplace PurchaseHardThe Church of Jesus Christ of Latter-day SaintsRank Customer Spend by DepartmentHardRevatureFirst and Last Purchase DatesEasy