5 个解决方案
#1
var
i: integer;
begin
with query do
begin
close;
sql.clear;
sql.add('select sum(colname) as sumcol from tablename');
open;
i:= fieldbyanem('sumcol').asinteger;
end;
end;
#2
i:=adoquery.recordcount;
#3
正确~~
#4
楼主说得不清楚,是不是求某字段唯一值的个数啊?
比如1,3,4,2,1 的唯一值个数是4,而不是5,是这样吗?
var
i: integer;
begin
with query do
begin
close;
sql.clear;
sql.add('select count(distinct colname) as sumcol from tablename');
open;
i:= fieldbyanem('sumcol').asinteger;
end;
end;
比如1,3,4,2,1 的唯一值个数是4,而不是5,是这样吗?
var
i: integer;
begin
with query do
begin
close;
sql.clear;
sql.add('select count(distinct colname) as sumcol from tablename');
open;
i:= fieldbyanem('sumcol').asinteger;
end;
end;
#5
i:=adoquery.datasourse.dataset.recordcount
#1
var
i: integer;
begin
with query do
begin
close;
sql.clear;
sql.add('select sum(colname) as sumcol from tablename');
open;
i:= fieldbyanem('sumcol').asinteger;
end;
end;
#2
i:=adoquery.recordcount;
#3
正确~~
#4
楼主说得不清楚,是不是求某字段唯一值的个数啊?
比如1,3,4,2,1 的唯一值个数是4,而不是5,是这样吗?
var
i: integer;
begin
with query do
begin
close;
sql.clear;
sql.add('select count(distinct colname) as sumcol from tablename');
open;
i:= fieldbyanem('sumcol').asinteger;
end;
end;
比如1,3,4,2,1 的唯一值个数是4,而不是5,是这样吗?
var
i: integer;
begin
with query do
begin
close;
sql.clear;
sql.add('select count(distinct colname) as sumcol from tablename');
open;
i:= fieldbyanem('sumcol').asinteger;
end;
end;
#5
i:=adoquery.datasourse.dataset.recordcount