TYPE RANGE SALES A 20180301-20180101 100 A 20171201-20171031 150 A 20170930-20170731 100 B 20180301-20180101 200 B 20171201- 20171031 200
TYPE 20180301-20180101 20171201-20171031 20170930-20170731 A 100 150 100
SELECT FROM ( SELECT TYPE,MONTH_RANGE,SALES FROM TABLE ) pivot ( SUM(SALES) FOR (MONTH_RANGE) IN (SELECT DISTINCT MONTH_RANGE FROM TABLE) )
pivot xml (SUM(SALES) for (month_range) in (SELECT DISTINCT MONTH_RANGE FROM TABLE))
for month_range in ('20180301-20180101')
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)