我想学习做一个彩票分析软件,排列于组合可以很快生成出来,但是我想生成出来的号码里面包含某些数字不知道怎么做
生成:
create table #number(T1 tinyint)
declare @T1 tinyint
SET @T1 = 1
WHILE @T1 <= 33
BEGIN
INSERT INTO #number VALUES(@T1)
SET @T1 = @T1 + 1
END
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
1.然后在这100多万注里有 1,2,3,4,5,6,7,8,9,10里1-3个号码的挑出来,超过4个以上的不显示出来怎么弄?
2.连号数字不需要5连号以上的数字,如1,2,3,4,5,8,最多4连号,并且连号对数不超过2个,如1,2,6,7,8,11
3.怎么计算遗漏值的,我有个历史开奖档,里面有T1,T2,T3,T4,T5,T6分别对应大小顺序排列的开奖记录
我想算下T1中的某个数字最大遗漏了多少期!怎么查
能解决以上问题者,膜拜,重谢,做了这个软件,我的算法又提升了一步,哈哈
生成:
create table #number(T1 tinyint)
declare @T1 tinyint
SET @T1 = 1
WHILE @T1 <= 33
BEGIN
INSERT INTO #number VALUES(@T1)
SET @T1 = @T1 + 1
END
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
1.然后在这100多万注里有 1,2,3,4,5,6,7,8,9,10里1-3个号码的挑出来,超过4个以上的不显示出来怎么弄?
2.连号数字不需要5连号以上的数字,如1,2,3,4,5,8,最多4连号,并且连号对数不超过2个,如1,2,6,7,8,11
3.怎么计算遗漏值的,我有个历史开奖档,里面有T1,T2,T3,T4,T5,T6分别对应大小顺序排列的开奖记录
我想算下T1中的某个数字最大遗漏了多少期!怎么查
能解决以上问题者,膜拜,重谢,做了这个软件,我的算法又提升了一步,哈哈
解决方案 »
- 求写时间段查询SQL
- 怎么建 月报表 日报表 明细表 谢谢
- %%是什么意思
- BIT数据类型到NVARCHAR数据类型的转换问题
- win8 怎么安装sql server2005,
- 使用smo备份
- 局域网里一台机器能访问另一台的sql server ,另一台不能访问这一台的sql server 是怎么回事?
- 关于select语句的问题
- 高分寻求做智能卡要用到C/C++、数据库中的哪些技术或其他相关技术均可,回答均有分
- 关于ORACLE8.1.5的存储过程的问题
- 请问sqlserver2008的那个版本微软不收费可以放心的用
- 请问各位高手怎么将大的文档或者图片输入到SQL server 2000数据库呢
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
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 or a2.t1=a3.t1-1 and a3.t1=a4.t1-1 and a4.t1=a5.t1-1 and a5.t1=a6.t1-1)
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.要根据你的历史记录表来对应处理,查是否相同就行.
-- 1.然后在这100多万注里有 1,2,3,4,5,6,7,8,9,10里1-3个号码的挑出来,超过4个以上的不显示出来怎么弄?with season as
(select a1.t1 n1, a2.t1 n2, a3.t1 n3, a4.t1 n4, a5.t1 n5, a6.t1 n6
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)
select * from season
where
(case when n1<=10 then 1 else 0 end+
case when n2<=10 then 1 else 0 end+
case when n3<=10 then 1 else 0 end+
case when n4<=10 then 1 else 0 end+
case when n5<=10 then 1 else 0 end+
case when n6<=10 then 1 else 0 end
)<=3
(select a1.t1 n1, a2.t1 n2, a3.t1 n3, a4.t1 n4, a5.t1 n5, a6.t1 n6
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)
select * from season
where
(case when n1<=10 then 1 else 0 end+
case when n2<=10 then 1 else 0 end+
case when n3<=10 then 1 else 0 end+
case when n4<=10 then 1 else 0 end+
case when n5<=10 then 1 else 0 end+
case when n6<=10 then 1 else 0 end
) between 1 and 3
--2.连号数字不需要5连号以上的数字,如1,2,3,4,5,8,最多4连号,并且连号对数不超过2个,如1,2,6,7,8,11with season as
(select a1.t1 n1, a2.t1 n2, a3.t1 n3, a4.t1 n4, a5.t1 n5, a6.t1 n6
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)
select * from season
where
not((n1+1=n2 and n2+1=n3 and n3+1=n4 and n4+1=n5) -- 排除5連號,6連號的.
or(n2+1=n3 and n3+1=n4 and n4+1=n5 and n5+1=n6)
or(n1+1=n2 and n2+1=n3 and n3+1=n4 and n4+1=n5 and n5+1=n6))--> 以上實現了一半,另一個需確認一下: 1 2 3 4 ... 算2對連號還是3對連號?
-- 3.怎么计算遗漏值的,我有个历史开奖档,里面有T1,T2,T3,T4,T5,T6分别对应大小顺序排列的开奖记录
-- 我想算下T1中的某个数字最大遗漏了多少期!怎么查--> 沒有表結構,以下是偽代碼供參考.
declare @t int
select @t=[某个数字]with t1 as
(select row_number() over(order by 期數) rn, [期數]
from [历史开奖档]
where (n1=@t or n2=@t or n3=@t or n4=@t or n5=@t or n6=@t)),
t2 as
(select b.[期數]-a.[期數] y
from t1 a
left join t1 b on a.rn=b.rn-1)
select max(y) '最大遗漏了期数' from y
期号int 不会重复的如2011141意思就是2011年第141期
关于连号,只要中间没有断,就算一对连号1234算一对4连号
-- 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