hafizy Baharudin hafizy Baharudin - 12 days ago 5
MySQL Question

MySql Group By and Sum total value of column, displayed with min value

I have to enquieries :


  1. How to group and sum a column.

  2. How to displayed the result with a min sum value



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

Answer

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;