有表如下
期号 第一位 第二为.......................第七位
1 3 4 5 12 6 8 9
2 7 9 7 14 14 10 11
.......
此表是用来显示体育彩票中奖号码的。我想体育彩票大家都玩过把
我的问题是 如何从上表中得到
号码 号码出现数
1 ? <--要求自动统计出来
2 ?
3 ?
4 .
5 .
6
7
8
9
10
.
.
.
29 ?
这张表 我想不出来 向各位请教 谢谢
期号 第一位 第二为.......................第七位
1 3 4 5 12 6 8 9
2 7 9 7 14 14 10 11
.......
此表是用来显示体育彩票中奖号码的。我想体育彩票大家都玩过把
我的问题是 如何从上表中得到
号码 号码出现数
1 ? <--要求自动统计出来
2 ?
3 ?
4 .
5 .
6
7
8
9
10
.
.
.
29 ?
这张表 我想不出来 向各位请教 谢谢
( select count(*) from tablename where col2 = 1) as 2,
( select count(*) from tablename where col3 = 1) as 3,
...
( select count(*) from tablename where col7 = 1) as 7,
from tablename
select( select count(*) from tablename where col1 = 1) +
( select count(*) from tablename where col2 = 1) +
( select count(*) from tablename where col3 = 1) +
...
( select count(*) from tablename where col7 = 1) as count,
from tablename
Ttable 功能太弱了
其他跟Ttable 一样,直接把上面大虾的代码写在sql里面就可以了!
怎么,还不会,干脆考过去算了!
建议用存储过程
var
num :Tstrings;
begin
str:=trim(str);
num:=tstringlist.Create;
while pos(' ',str)>0 do
begin
trim(str);
num.Add(copy(str,1,pos(' ',str)));
delete(str,1,pos(' ',str));
pos(' ',str);
end ;
num.Add(str);
Result:=num;
end;
function Getnum(var str:string ):Tstrings;
var
num :Tstrings;
begin
str:=trim(str);
num:=tstringlist.Create;
while pos(' ',str)>0 do
begin
trim(str);
num.Add(copy(str,1,pos(' ',str)));
delete(str,1,pos(' ',str));
pos(' ',str);
end ;
num.Add(str);
Result:=num;
end;
var
txtfile,strl:Tstrings;
i,ii,iii:integer;
str:string;
num:array[0..34] of integer;
begin
for I := 0 to 34 do num[I]:=0;
txtfile:=tstringlist.Create;
txtfile.LoadFromFile('c:\data.txt');
for i:=0 to txtfile.Count-1 do
begin
str:=txtfile.Strings[i];
strl:=tstringlist.Create;
strl:=Getnum(str);
for ii:=0 to strl.Count-1 do
begin
num[strtoint(strl.Strings[ii])-1]:=num[strtoint(strl.Strings[ii])-1]+1;
end; end;
for iii:=0 to 34 do
showmessage(intostr(iii+1)+'的次数'+inttostr(num[iii]));
end;