_覓 | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁 |
FrontPage › 3一豪Μ
|
|
螳 id螳 螳 磯殊 3覯 一朱 豪Μ 螳 觸螻 蟆曙磯. 讌レ 覦磯 覓殊企 襯 襷れ企瓦. れ 螻 蟾襾豪.
[edit]
1 覦覯1 #drop table #temp create table #temp(id varchar(20), win bit, dt datetime default getdate()) insert #temp(id, win) values ('a', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('a', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('a', 0) waitfor delay '00:00:01' insert #temp(id, win) values ('a', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('a', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('a', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('b', 0) waitfor delay '00:00:01' insert #temp(id, win) values ('b', 0) waitfor delay '00:00:01' insert #temp(id, win) values ('b', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('b', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('b', 1) waitfor delay '00:00:01' --insert #temp(id, win) values ('b', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('b', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('b', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('b', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('b', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('b', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('b', 0) waitfor delay '00:00:01' insert #temp(id, win) values ('b', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('b', 1) waitfor delay '00:00:01' insert #temp(id, win) values ('b', 1) ;with temp as ( select * , row_number() over(partition by id order by dt) rownum from #temp ), rs1 as ( select --* a.id , a.rownum , max(b.rownum) max_rownum , max(b.dt) max_dt , isnull(count(case when b.win = 1 and a.rownum-b.rownum <> 1 then 1 end),0) cnt , isnull(min(case when a.rownum-b.rownum = 1 then convert(int,b.win) end),0) prev1_row from temp a inner join temp b on a.id = b.id and a.rownum in (b.rownum+1, b.rownum, b.rownum-1, b.rownum-2) group by a.id , a.rownum having isnull(count(case when b.win = 1 and a.rownum-b.rownum <> 1 then 1 end),0) = 3 ), rs2 as ( select *, row_number() over(partition by id order by rownum) rownum2 from rs1 ) select * from rs2 where prev1_row = 0 or rownum2 % 3 = 1 order by id, rownum
鏤
|
一 レ . 蠏碁覃 轟蟆 る 螳 殊 襷 襷譟煙る 蟆企. 豺蟲れ 轟 襦 轟 蠏碁れ蟆 譴る 轟 螻 至鍵 蠏碁れ 襦 譬 豺蟲れ 譴 蟆企. 襦燕襦郁 襷 豺蟲襯 螳讌る 豺蟲螳 企. (企 るΠろ "蟆壱狩讌 讀蟇一"筝) |