没见过你这样的case 写法,,,
Declare @countTemp30 float,@countTemp80 float,@countTemp100 float
select(Case When sumTempAve100>sumTempAve80 Then @countTemp100+1 else '' end),
(case When sumTempAve80>sumTempAve30 And sumTempAve30>sumTempAve10 Then @countTemp80+1 else '' end),
(CASE When sumTempAve30>sumTempAve10 Then @countTemp30+1 ELSE '' end)
From (SELECT Year,Month,Day,Hour, sum(TEMPERATUREAVERAGE10) as sumTempAve10, sum(TEMPERATUREAVERAGE30) as sumTempAve30,sum(TEMPERATUREAVERAGE80) as sumTempAve80,sum(TEMPERATUREAVERAGE100) as sumTempAve100
FROM (SELECT DATEPART(yyyy,SystemReportTime) AS Year,DATEPART(mm,SystemReportTime) AS Month,DATEPART(dd,SystemReportTime) AS Day,DATEPART(hh,SystemReportTime) AS Hour,TEMPERATUREAVERAGE10,TEMPERATUREAVERAGE30,TEMPERATUREAVERAGE80,TEMPERATUREAVERAGE100 FROM METDATA WHERE SYSTEMREPORTTIME >= '2013-01-01 00:00:00' AND SYSTEMREPORTTIME <= '2014-01-01 00:00:00' ) AS T_d GROUP BY Year, Month,Day,Hour ) as t_d
这样,看是不是你想要的
所有的Case结束都要用End,你有几个case没有用end结束