怎么加入判断条件!
with [temps] as ( select row_number() over(PARTITION BY LID order by RID Desc) as TID,LID,Result from Results ) select Lid,sum(case when TID>=1 and TID <=10 then 1 else 0 end) as [C010] from temps where Result = 1 GROUP BY Lid
with [temps] as ( select row_number() over(PARTITION BY LID order by RID Desc) as TID, LID,Result from Results ) select Lid,sum(case when TID>=1 and TID <=10 then 1 else 0 end) as [C010] from temps where Result = 1 GROUP BY Lid having sum(case when TID>=1 and TID <=10 then 1 else 0 end)>N
[解决办法]
with [temps] as ( select row_number() over(PARTITION BY LID order by RID Desc) as TID,LID,Result from Results )select Lid,sum(case when TID>=1 and TID <=10 then 1 else 0 end) as [C010] from temps where Result = 1GROUP BY Lidhaving sum(case when TID>=1 and TID <=10 then 1 else 0 end) > N
[解决办法]
;with [temps] as(select row_number()over(PARTITION BY LID order by RID desc) as TID,gLid,result from results)select Lid,sum(case when Tid>=1 and TID<=10 then 1 else 0 end) as [c010]from temps where Result=1group by Lidhaving sum(case when Tid>=1 and Tid<=10 then 1 else 0 end)>N
[解决办法]
sql 语句博大精深哈,row_number()over(PARTITION BY LID order by RID desc)类似的几种用法昨天做报表时第一次用到,呵呵感觉不错哈。
[解决办法]
PARTITION BY 字句功能确实很强大,学习了!
[解决办法]
学习一下,都是几十年的语言了,强大是必须的
[解决办法]
with [temps] as(select row_number() over(PARTITION BY LID order by RID Desc) as TID,LID,Result from Results)select Lid,sum(case when TID>=1 and TID <=10 then 1 else 0 end) as [C010]from temps where Result = 1 GROUP BY Lidhaving sum(case when TID>=1 and TID <=10 then 1 else 0 end)>N