Customers Who Bought at Most One Product
Updated
Problem statement
The customers table has one row per customer: a unique customer_id and the customer_name.
The purchases table has one row for each product a customer bought: a unique purchase_id, the customer_id of the buyer, and the product_name.
Find every customer who bought at most one product. A customer who bought nothing has bought zero products, so that customer counts too.
Return one column, customer_name, with one row per matching customer. Two different customers can have the same name; list each of them. Sort the rows by customer_name from A to Z.
Table schema
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
customers
One row per customer.
| Column | Type | Nullable | Description |
|---|---|---|---|
| customer_idPK | Integer | No | — |
| customer_name | Text | No | — |
purchases
One row for each product a customer bought.
| Column | Type | Nullable | Description |
|---|---|---|---|
| purchase_idPK | Integer | No | — |
| customer_id | Integer | No | — |
| product_name | Text | No | — |
Foreign key: customer_id → customers(customer_id)
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| customer_name | Text | No | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- Each table has from
0to1000rows. customer_idis unique incustomers, andpurchase_idis unique inpurchases.1 <= customer_id, purchase_id <= 10^6- Every
customer_idinpurchasesalso appears incustomers. - A customer buys a given
product_nameat most once. customer_nameis one uppercase English letter followed by 0 to 19 lowercase English letters. Names can repeat.product_namehas 1 to 20 lowercase English letters.- No value is
NULL.
More Expedia Online Assessment questions
- Balanced NumbersOA · Seen Aug 2026
- REST API: Discounted PriceOA · Seen Aug 2026
- Maximum Team SizeOA · Seen Mar 2026
- Per-Domain Request LimiterOA · Seen Oct 2025
- Count Equal-Frequency SubsequencesOA · Seen Mar 2025
- Count Increasing Stock PeriodsOA · Seen Mar 2025
- Get Minimum StepsOA · Seen Oct 2024
- Rank Songs by PopularityOA · Seen Oct 2024
- Calculate the SumOA · Seen Oct 2024
- Get Maximum EfficiencyOA · Seen Oct 2024
Similar questions at other companies
- Students Scoring Above AverageCapstone Investment Advisors · OA
- Bond Interest Summary Above 3%Wells Fargo · OAWells Fargo interview questions
- Employee Promotion OpportunitiesIntuit · OAIntuit interview questions
- Students and Their SubjectsBirla Pivot · OA
- Companies with Average Salary Above 40000AT&T · OAAT&T interview questions
- Build Taxi Driver Performance FeaturesBoston Consulting Group · OABoston Consulting Group interview questions
- Weekend Appointments for Consular Services ReschedulingMcKinsey & Company · OAMcKinsey & Company interview questions
- Companies Above a Salary ThresholdVerisk · OA
- Customer Resource Usage AnalysisIBM · OAIBM interview questions
- Customers Who Never OrderedAccenture · OAAccenture interview questions
Interview reports that mention this question
Expedia interview experiences
- Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
- Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
- Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
- Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
- Expedia SWE Intern Final Round: 126 Experiences (Part 1 of 6)