15. Using the Pivot Operator

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 company that markets its products online, is using the following table to store all sales that took place in the years 2001-2002. As you can see, this table is composed of two columns – purchase date and the purchase amount.

CREATE TABLE Purchases   
(PurchaseDate varchar(25),   
 SoldAmount int)  

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…