语法错误,分给多点.试试!
select STime,SDyp=(
select sum(SDyp) from(
select top 120 SDyp from (SELECT sum(SDyp) as SDyp,STime FROM @REC GROUP BY STime) X
where X.STime>=a.STime
)aa having count(*)=120)
from (SELECT sum(SDyp) as SDyp,STime as STime FROM @REC GROUP BY STime) a
服务器: 消息 207,级别 16,状态 3,行 34
列名 'STime' 无效。