select max(count(od_product_id)) as no from order_detail group by od_product_id
在查询上方不起作用。
答案 0 :(得分:1)
您正尝试按要汇总的列进行分组
试试这个:
select max(counted)
from
(
select od_product_id, count(*) as counted
from order_detail
group by od_product_id
) x1
答案 1 :(得分:0)
您可以将HAVING
用于此
SELECT od_product_id, COUNT(od_product_id) AS c
FROM order_detail
GROUP by od_product_id
HAVING count(od_product_id) >= ALL
(
SELECT count(od_product_id)
FROM order_detail
GROUP by od_product_id
)