It is very easy to remove values ββthat you do not want to aggregate.
For instance:
SELECT department, SUM(sales) as "Total sales" FROM order_details GROUP BY department HAVING SUM(sales) > 1000;
Which excludes all sales with a value less than or equal to 1000 from the summation.
But how do you filter after aggregation?
For example, WHERE ("Total sales"> 15000)
Edit: ironically, I only HAVING SUM(sales) > 1000; to avoid confusion regarding the type of request being requested; because I'm not really interested in excluding items from the summation, only the returned results! Thank you, despite the confusion!
source share