Nov 20, 2003 #1 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.
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.
Nov 20, 2003 #2 nicsin Programmer Jul 31, 2003 743 GB Hi, you could try: select sum(query1.field1) from (select field1 from table1) as query1 nicsin Upvote 0 Downvote
Nov 20, 2003 #3 JonFer Programmer Nov 7, 2003 868 US 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) Upvote 0 Downvote
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)
Nov 20, 2003 Thread starter #4 Harr777 Programmer Sep 25, 2003 71 US I see, it's like getting the sum of a value in a table. Thanks for putting up with my newness. Upvote 0 Downvote
Nov 20, 2003 #5 nicsin Programmer Jul 31, 2003 743 GB Yep! you can treat any query as a table. it is just a recordset after all.... ;-) Upvote 0 Downvote
Nov 20, 2003 #6 nicsin Programmer Jul 31, 2003 743 GB well...having said that, don't get too excited and start inserting records! it won't happen Upvote 0 Downvote