答案 0 :(得分:0)
应该对子查询进行简单的分组。
SELECT agent_code, ord_amount, cust_code, count(*)
FROM (SELECT distinct agent_code, ord_amount, cust_code
FROM orders
WHERE agent_code = 'A0002')
GROUP BY agent_code, ord_amount, cust_code
有更复杂的方法可以替代,但这似乎是最简单的。