Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the total of column in other query

Status
Not open for further replies.

Harr777

Programmer
Sep 25, 2003
71
US
I'm trying to get the sum of a column which is the result of another query. I'm not sure how to get that value.
Thanks in advance.
 
Hi,

you could try:

select sum(query1.field1) from (select field1 from table1) as query1

nicsin
 
Is the result of the other query a single value or multiple records?

If there are multiple records, your query to get the sum should use this field expression:

SumOther: (Select Sum(field1) from otherquery)

If you need to restrict which records in otherquery get included, you need to do this:

SumOther: (Select Sum(a.field1) from otherquery as a
Where a.KeyField=thisquery.KeyField)

 
I see, it's like getting the sum of a value in a table.
Thanks for putting up with my newness.
 
Yep! you can treat any query as a table. it is just a recordset after all.... ;-)
 
well...having said that, don't get too excited and start inserting records! it won't happen :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top