Reputation: 87
I have two questions:
I got my 1st answer here on how to group and sum the column, but I need to filter out by min amount of 100 ..
I tried
SELECT
member_code, SUM(product_price) as totalSales
FROM
src_calculation_daily
WHERE
totalSales > 100
GROUP BY
member_code
Any help is much appreciated. Thank you
Upvotes: 0
Views: 92
Reputation: 1577
You are looking for HAVING
SELECT member_code, sum(product_price) as totalSales FROM src_calculation_daily GROUP BY member_code HAVING totalSales > 100
WHERE is used when the fields exists in your table
HAVING is used on a calculated value
Upvotes: 1
Reputation: 1269873
I think you just want a HAVING
clause:
SELECT member_code, sum(product_price) as totalSales
FROM src_calculation_daily
GROUP BY member_code
HAVING totalSales > 100;
Upvotes: 3