• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 140
  • Last Modified:

total money have in a grid column

How can i calculate or get the total of a currency value in a grid COLUMN.  
(database paradox)
ex.
     price

     100.00
     300.00
     150.00
     ======
     550.00
0
mvalez
Asked:
mvalez
  • 4
1 Solution
 
rwilson032697Commented:
Try this in a TQuery:

Select Total as Sum(Price) from TheTable

Then you will have one row in the result set with one field with the value you want!

OR you can run through all the rows yourself and add them up like this

Total := 0
while not Query.EOF do
  begin
    Total := Total := Query.FieldsByName['Price'].AsFloat;
    Query.Next;
  end;

Cheers,

Raymond.
0
 
rwilson032697Commented:
Err.. THe second := should be a +     :-(
0
 
mvalezAuthor Commented:
Thank you very much...
0
 
rwilson032697Commented:
Glad to help!

Cheers,

Raymond.
0
 
rwilson032697Commented:
Hmm...

I think this:

Select Total as Sum(Price) from TheTable

should read:

Select Sum(Price) as Total from TheTable

Cheers,

Raymond.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now