Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
First Product Purchased Per Customer
00:00
5 left

First Product Purchased Per Customer

EasySQL · PostgreSQL

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
Tablescustomersordersproducts
Interviewer

Your question is First Product Purchased Per Customer. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.