27,580
社区成员
发帖
与我相关
我的任务
分享
select
top 1 *
from
( select
min([年月日]) as bgdate, max([年月日]) as eddate, count(1) as maxdays
from
(select
[年月日], datediff(dd, '1900-01-01', a.[年月日]) - (select count(1) from ##DateData58549 b where [日平均温度] >= 10 and datediff(dd, b.[年月日], a.[年月日]) >= 0) as maxdays
from
##DateData58549 a
where
[日平均温度] >= 10) as a
group by
maxdays
having COUNT(1) >= 5
) as b
order by bgdate
只要一天的话可以TOP1就可以了 A和B都是因为在包含子查询以后需要加个别名 相当于AS A ,AS B这样