select
*
from sap_stockmaster
where itemid=9893
and salemrp=1034.00
and salemrp in(
select
salemrp
from sap_stockmaster
where SUM(stkqty)>0
)
order by salemrp desc
I want record whose Sum of Quantity is greater than Zero but get the following error
An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference.
wheretohavingand precede it with agroup by salemrpon the subquery. - xQbertwhere stkqty > 0? - Lasse V. KarlsenSUM(stkqty) > 0in theHavingclause. - SS_DBA