为了账号安全,请及时绑定邮箱和手机立即绑定

如下内容,请问该怎么转换成sql server语句?

如下内容,请问该怎么转换成sql server语句?

慕桂英4014372 2022-04-16 17:13:26
oracle语句select IDfrom (select ID,time,coun,lag(coun, 1) over(partition by ID order by time) lag_coun1,lag(coun, 2) over(partition by ID order by time) lag_coun2,lag(coun, 3) over(partition by ID order by time) lag_coun3,lag(coun, 4) over(partition by ID order by time) lag_coun4,lag(coun, 5) over(partition by ID order by time) lag_coun5,lag(coun, 6) over(partition by ID order by time) lag_coun6from (select ID, trunc(add_time, day) time, count(*) counfrom tablewhere time > 10and time < 24group by ID, trunc(add_time)))where coun > 30and lag_coun1 > 30and lag_coun2 > 30and lag_coun3 > 30and lag_coun4 > 30and lag_coun5 > 30and lag_coun6 > 30谁能帮我转换成sql server语句
查看完整描述

2 回答

?
吃鸡游戏

TA贡献1829条经验 获得超7个赞

select ID
from (select ID,
time,
coun,
lag(coun, 1) over(partition by ID order by time) lag_coun1,
lag(coun, 2) over(partition by ID order by time) lag_coun2,
lag(coun, 3) over(partition by ID order by time) lag_coun3,
lag(coun, 4) over(partition by ID order by time) lag_coun4,
lag(coun, 5) over(partition by ID order by time) lag_coun5,
lag(coun, 6) over(partition by ID order by time) lag_coun6
from (select ID, trunc(add_time, day) time, count(*) coun
from table
where time > 10
and time < 24
group by ID, trunc(add_time)))
where coun > 30
and lag_coun1 > 30
and lag_coun2 > 30
and lag_coun3 > 30
and lag_coun4 > 30
and lag_coun5 > 30
and lag_coun6 > 30



查看完整回答
反对 回复 2022-04-19
?
慕的地8271018

TA贡献1796条经验 获得超4个赞

只需要把oracle 中turnc 函数 换成SQL Server的函数就可以!
trunc(add_time, day) --CONVERT(varchar(100),add_time, 23)

查看完整回答
反对 回复 2022-04-19
  • 2 回答
  • 0 关注
  • 173 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信