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

Comparing results from sum(*) using HAVING

Status
Not open for further replies.

jazo1999

MIS
Nov 30, 2005
1
DK
Hi, I have a problem using HAVING in my query. It's a big query and I post a part of it, hope it's enough to solve the problem. What i want to do is to compare the Q.result with a given number, say bigger than 1000. Is this possible by using HAVING, and if so, what am I doing wrong??
thanx


SELECT I2.i_name
FROM Ingredients2 I2,((SELECT II.i_name,Sum(II.amount) AS result
FROM ingred_is_in2 II
GROUP BY II.i_name) Q
HAVING (Q.result)>1000)
WHERE I2.currentamount <= Q.result
 
i didn't get your idea
also it was better to give what is actually your problem (the postgresql raises an error, what error; or the results from the query, are not what you expected ....)

here is a little modified version, because I think, your version is with wrong syntax


SELECT I2.i_name
FROM Ingredients2 I2,(SELECT II.i_name,Sum(II.amount) AS result
FROM ingred_is_in2 II
GROUP BY II.i_name HAVING (Q.result)>1000) Q
WHERE I2.currentamount <= Q.result
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top