Sum problem, help..

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Problem is this... I have 2 fields in a table, both are numeric. I want the grand total of both fields combined. So if the sum of fieldA is 10, and field B is 10, I want it to find the answer 20. I know nothing of SQL except what I've read so far on here and in my book, which is quite basic. What is the easiest solution? I can't seem to get the union query to do what I want. Any help is greatly appreciated.... thanks for your tim

Josh S
 
Try something along the lines of
SELECT (Sum(Nz(fieldA,0)) + Sum(Nz(fieldB,0))) AS
GrandTotal FROM YourTable

The inclusion of the Nz function allows for the possibility
of all the fields being Null. You will have to change
fieldA, fieldB and YourTable to suit your app.

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
Problem is this... I have 2 fields in a table, both are
numeric. I want the grand total of both fields combined.
So if the sum of fieldA is 10, and field B is 10, I want it
to find the answer 20. I know nothing of SQL except what
I've read so far on here and in my book, which is quite
basic. What is the easiest solution? I can't seem to get
the union query to do what I want. Any help is greatly
appreciated.... thanks for your time
 
Add a new field in the query designer as follows

GTot: Sum(Field3 + Field4


----- Josh S wrote: ----

Problem is this... I have 2 fields in a table, both are numeric. I want the grand total of both fields combined. So if the sum of fieldA is 10, and field B is 10, I want it to find the answer 20. I know nothing of SQL except what I've read so far on here and in my book, which is quite basic. What is the easiest solution? I can't seem to get the union query to do what I want. Any help is greatly appreciated.... thanks for your tim

Josh S
 
SELECT Sum(Table1.fld1) AS Sumfld1, Sum(Table1.fld2) AS
Sumfld2, [Sumfld1]+[Sumfld2] AS GrandTot
FROM Table1;

-----Original Message-----
Problem is this... I have 2 fields in a table, both are
numeric. I want the grand total of both fields combined.
So if the sum of fieldA is 10, and field B is 10, I want
it to find the answer 20. I know nothing of SQL except
what I've read so far on here and in my book, which is
quite basic. What is the easiest solution? I can't seem
to get the union query to do what I want. Any help is
greatly appreciated.... thanks for your time
 
Back
Top