with Produce AS ( SELECT 'Kale' as product, 'good' as sales, 'Q1' as quarter UNION ALL SELECT 'Kale', 'bad', 'Q2' UNION ALL SELECT 'Kale', 'good', 'Q3' UNION ALL SELECT 'Kale', 'bad', 'Q4' UNION ALL SELECT 'Apple', 'bad', 'Q1' UNION ALL SELECT 'Apple', 'good', 'Q2' UNION ALL SELECT 'Apple', 'bad', 'Q3' UNION ALL SELECT 'Apple', 'good', 'Q4') SELECT * FROM (SELECT product, sales, quarter FROM Produce) PIVOT(MAX(sales) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'))
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter