fbpx

17. Pivoting Without Aggregation

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.
 

As seen in the previous exercises, using the Pivot operator allows displaying values in an axis table.
Using aggregate functions (such as Sum) is an insepartable part of the syntax, however, what happens when no grouping is necessary? For example, given the following Orders table, which contains ordered products and their amount.

CREATE TABLE orders   
(orderID int,   
 productName varchar(25),   
 productAmount int)  
 GO 

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…