var
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select sum(a8) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
Close;
end;
end;
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select sum(a8) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
Close;
end;
end;
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select Round(sum(a8),2) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
Close;
end;
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select sum(a8) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
caption=Format('%8.2f',[a]);
Close;
end;
end;
也可以考虑CONVERT或CAST
如果不怕麻烦
可以用pos函数定位字符串中的小数点,然后用copy函数取子串