This advanced SQL exercise is part of the book: Advanced SQL – Practical Techniques and Use-Cases, which includes 100 day-to-day SQL challenges (and solutions), need-to-know advanced features, and key concepts.

A clothing store manages a table that specifies various purchases made by its customers. As can be seen, each row indicates the customer number and 3 different purchases he has made. For example: Customer no. 1 has purchased the following products: Product A, Product B, and Product C.

CREATE TABLE purchases
(customer_id int,
purchase_1 varchar(25),
purchase_2 varchar(25),
purchase_3 varchar(25))

Would you like to read more?