日期:2014-05-17 浏览次数:20463 次
select alias,market,today.[中石油] as 'today中石油',today.[中石化] as 'today中石化',today.[中海油] as 'today中海油',today.[社会单位] as 'today社会单位' from Dic_Organization left join (select * from (select Province,Organization,Petrol93 from Sys_ReportData_01 left join Sys_GasStationInfo on Sys_ReportData_01.ObjectId = Sys_GasStationInfo.ID where Sys_ReportData_01.ReportDate>='2012-08-14 00:00:00' and Sys_ReportData_01.ReportDate<='2012-08-14 23:59:59')todaytemp pivot ( avg(Petrol93) for Organization in ([中石油],[中石化],[中海油],[社会单位]) )todayPivot )today on today.Province=Dic_Organization.ID left join (select * from (select Province,Organization,Petrol93 from Sys_ReportData_01 left join Sys_GasStationInfo on Sys_ReportData_01.ObjectId = Sys_GasStationInfo.ID where Sys_ReportData_01.ReportDate>='2012-08-13 00:00:00' and Sys_ReportData_01.ReportDate<='2012-08-13 23:59:59')todaytemp pivot ( avg(Petrol93) for Organization in ([中石油],[中石化],[中海油],[社会单位]) )lastdayPivot) lastday on lastday.Province=Dic_Organization.ID where CategoryID = 4
lastday.[中石油] as 'lastday中石油',lastday.[中石化] as 'lastday中石化',lastday.[中海油] as 'lastday中海油',lastday.[社会单位] as 'lastday社会单位'
select alias,market,today.[中石油] as 'today中石油',today.[中石化] as 'today中石化',today.[中海油] as 'today中海油',today.[社会单位] as 'today社会单位',lastday.[中石油] as 'lastday中石油',lastday.[中石化] as 'lastday中石化',lastday.[中海油] as 'lastday中海油',lastday.[社会单位] as 'lastday社会单位' from Dic_Organization left join (select * from (select Province,Organization,Petrol93 from Sys_ReportData_01 left join Sys_GasStationInfo on Sys_ReportData_01.ObjectId = Sys_GasStationInfo.ID where Sys_ReportData_01.ReportDate>='2012-08-14 00:00:00' and Sys_ReportData_01.ReportDate<='2012-08-14 23:59:59')todaytemp pivot ( avg(Petrol93) for Organization in ([中石油],[中石化],[中海油],[社会单位]) )todayPivot )today on today.Province=Dic_Organization.ID left join (select * from (select Province,Organization,Petrol93 from Sys_ReportData_01 left join Sys_GasStationInfo on Sys_ReportData_01.ObjectId = Sys_GasStationInfo.ID where Sys_ReportData_01.ReportDate>='2012-08-13 00:00:00' and Sys_ReportData_01.ReportDate<='2012-08-13 23:59:59')todaytemp pivot ( avg(Petrol93) for Organization in ([中石油],[中石化],[中海油],[社会单位]) )lastdayPivot) lastday on lastday.Province=Dic_Organization.ID where CategoryID = 4