aebstract Posted January 5, 2010 Share Posted January 5, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/187270-aggregate-function-in-query/ Share on other sites More sharing options...
aebstract Posted January 5, 2010 Author Share Posted January 5, 2010 HAVING has to be after GROUP, didn't notice that. Quote Link to comment https://forums.phpfreaks.com/topic/187270-aggregate-function-in-query/#findComment-988913 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.