我有3列
detail_id, item_id, item_qty
我想:
SELECT detail_id FROM tbl_details WHERE SUM(item_qty) = some value
我试图在这里找到答案但失败了,如果有人可以提供简单有效的查询,我将非常感谢您的帮助。
此致
答案 0 :(得分:1)
尝试使用拥有子句
text/plain
答案 1 :(得分:0)
您不能将WHERE
子句用于聚合函数..使用Group BY & Having
.. this discussion。 e.g ...
SELECT detail_id , SUM(item_qty) total_item
FROM tbl_details
GROUP BY detail_id
HAVING total_item = some_value