Re:SELECT SUM
Quote
>Hellody
>Can you help me? PLEASE?
>I am learning Delphi 4 and SQL... I want to exec a query to return the
>total of a selection of rows...eg:
>SELECT SUM (budgets) sum_of_budgets
>FROM project
>WHERE ....
>Is that the right syntax? (to total a field called budgets).
>Assuming it is correct, how do i return the sum_of_budgets into
>a variable in my delphi code?
>I hope that makes sense. What i want to do is very simple but my
>explanation may be complex!!!
>Cheers for any help.....
>Jon
Use a TQuery Object
Assign its DatabaseName property and then
in the SQL property wqrite your query
After that, click x 2 the component and you will see
a smallish window appear. Press Ins and you'll
see a list of fields. To add all of them press OK.
You have just created an object for each field.
ie. Query1 : TQuery, SUM_WHATEVER Field (integer) in the query
will get you a Query1SUM_WHATEVER : TIntegerFiled
you can use it like this:
Something := Query1SUM_WHATEVER.AsInteger;
Kind regards,
Konstantin V {*word*224}ov aka JHVHS
jh...@quadrus.ru
Quadrus-M http://www.quadrus.ru