日期:2014-05-18 浏览次数:20925 次
select * from #number a1,#number a2,#number a3,#number a4,#number a5,#number a6 where a1.t1 < a2.t1 and a2.t1 < a3.t1 and a3.t1 < a4.t1 and a4.t1 < a5.t1 and a5.t1 < a6.t1 and (case when a1.t1<=10 then 1 else 0 end)+ (case when a2.t1<=10 then 1 else 0 end)+ (case when a3.t1<=10 then 1 else 0 end)+ (case when a4.t1<=10 then 1 else 0 end)+ (case when a5.t1<=10 then 1 else 0 end)+ (case when a6.t1<=10 then 1 else 0 end) between 1 and 3
------解决方案--------------------
2.2 三连号必定是三对:
select * from #number a1,#number a2,#number a3,#number a4,#number a5,#number a6 where a1.t1 < a2.t1 and a2.t1 < a3.t1 and a3.t1 < a4.t1 and a4.t1 < a5.t1 and a5.t1 < a6.t1 and not(a1.t1=a2.t2-1 and a2.t1<>a3.t1-1 and a3.t1=a4.t1-1 and a4.t1<>a5.t1-1 and a5.t1=a6.t1-1)
------解决方案--------------------
-- 3.怎么计算遗漏值的,我有个历史开奖档,里面有T1,T2,T3,T4,T5,T6分别对应大小顺序排列的开奖记录 -- 我想算下T1中的某个数字最大遗漏了多少期!怎么查 --> 沒有表結構,以下是偽代碼供參考. declare @t int select @t=[某个数字] with t0 as (select row_number() over(order by QIHAO) rn, QIHAO, T1,T2,T3,T4,T5,T6 from HISTORY), t1 as (select row_number() over(order by QIHAO) rn2,* from t0 where T1=@t or T2=@t or T3=@t or T4=@t or T5=@t or T6=@t), t2 as (select b.rn-a.rn y from t1 a left join t1 b on a.rn2=b.rn2-1) select max(y) '最大遗漏了期数' from t2