我已經在sql開發人員中使用兩個表來確定哪個客戶放置了我獲得的最多訂單,以便找出每個客戶放置的訂單總數,但無法弄清楚如何只顯示了一個與訂單的最大數量...確定大部分訂單的客戶
對於示例 - 這會給我是誰下訂單的所有客戶的名單和他們每個人都下訂單的數量
SELECT
customer.cust_num, customer.cust_bizname,
COUNT(invoice.inv_num) AS "TOTAL ORDERS"
FROM customer INNER JOIN invoice ON customer.cust_num = invoice.cust_num
GROUP BY customer.cust_num, customer.cust_bizname;
如果我嘗試一起使用max和count ...
SELECT
customer.cust_num, customer.cust_bizname,
MAX(COUNT(invoice.inv_num)) AS "TOTAL ORDERS"
FROM customer INNER JOIN invoice ON customer.cust_num = invoice.cust_num
GROUP BY customer.cust_num, customer.cust_bizname;
我收到一個錯誤,指出「不是單組功能」。 如何有效計算訂單數量並僅顯示訂單數量最多的客戶?