Chapter 5 · JOINs
18. Customers in the Same City
Medium20 XPE-Commerce
Find pairs of customers who live in the same city. Return the first customer's full name as customer_1, the second customer's full name as customer_2, and the city. Show each pair once: customer_1 must be the customer with the smaller id, and never pair a customer with themselves. Sort by city, then customer_1, then customer_2.
Tables
- PKidINT
- first_nameTEXT
- last_nameTEXT
- emailTEXT
- phoneTEXT
- cityTEXT
- stateTEXT
- countryTEXT
- created_atTIMESTAMP
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.