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