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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting sum of column within a joint query 1

Status
Not open for further replies.

southbeach

Programmer
Jan 22, 2008
879
US
Wondering if this is at all possible - For now, I am running two query.
(1) First query searches for all records in table A
(2) Using a while loop to display data grid
(3) Within loop, running a 2nd query against table B to get the SUM of two columns

I tried running a single query but was not able to get it to work. Here is what I tried:
Code:
SELECT a.*, b.SUM(reserved) as QtyRes, b.SUM(available) as QtyAvl FROM header a, detail b WHERE a.key = varKey AND a.linkField = b.linkField

I get the error: b.SUM is not a function

Is there logic to my madness? How can I get this to work on a single query?

Thank you all for your assistance
 
syntax error is b.SUM should be

select sum(b.reserved)

if you want sum of 2 columns then

select sum(b.reserved+b.available)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top