我有两个问题:
我得到了第一个答案here 关于如何对列进行分组和求和,但我需要按最小量100来过滤..
我试过
SELECT
member_code, SUM(product_price) as totalSales
FROM
src_calculation_daily
WHERE
totalSales > 100
GROUP BY
member_code
非常感谢任何帮助。谢谢
答案 0 :(得分:3)
我想你只想要一个HAVING
条款:
SELECT member_code, sum(product_price) as totalSales
FROM src_calculation_daily
GROUP BY member_code
HAVING totalSales > 100;
答案 1 :(得分:1)
您正在寻找HAVING
SELECT member_code, sum(product_price) as totalSales FROM src_calculation_daily GROUP BY member_code HAVING totalSales > 100
当表格中存在字段
时使用WHEREHAVING用于计算值