81. Horizontal Sorting

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))

To read more

UpScale Analytics is one of the largest platforms in the world for learning SQL by doing, consisting over 300 SQL exercises at different levels (including solutions), by topics, across over 100 different datasets. More…