问题
Hi I have sql table I want to calculate all the fields to total sum field.
回答1:
You can do this in the SELECT statement you use to get the data, something like
SELECT *, big1 + small1 as "TotalSum" from adlar
Obviously, you can add more numeric fields to the fields to sum.
回答2:
procedure TForm1.Button1Click(Sender: TObject);
begin
ADOQuery1.Close;
ADOQuery1.SQL.Text:='select boyuk1 + kicik1 + qara1 + boyuk2 + kicik2 + boyuk3 * 0,35 as totalsum from adlar2v'; //(table name:adlar2v)
ADOQuery1.Open;
end;
来源:https://stackoverflow.com/questions/37291757/how-can-i-calculate-sql-tables-in-delphi