Jump to content

Aggregate function in query


aebstract

Recommended Posts

Okay I'm needing to do some basic math to determine whether or not to grab the results. What I have right now is:

WHERE SO.TOTALTAX+SUM(SOITEM.TOTALPRICE)-SUM(POSTRANSACTION.AMOUNT) > 0

 

I'm getting an error saying:

CANNOT USE AN AGGREGATE FUNCTION IN A WHERE CLAUSE, USE HAVING INSTEAD

 

I tried remove this line from the what section and added

HAVING SO.TOTALTAX+SUM(SOITEM.TOTALPRICE)-SUM(POSTRANSACTION.AMOUNT) > 0

 

With this I get a new error message:

DYNAMIC SQL ERRORSQL ERROR CODE = -104 TOKEN UNKOWN - LINE 31, COLUMN 1GROUP
Link to comment
https://forums.phpfreaks.com/topic/187270-aggregate-function-in-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.