SELECT id,icon,type,cnt
FROM capability
JOIN (
SELECT s0_.capability_id AS capability_id0 ,
count(capability_id) as cnt
FROM service_offer_capability s0_
INNER JOIN service_offer s1_ ON s0_.service_offer_id = s1_.id
WHERE s0_.value <> 'i:0;' AND s1_.service_id = 2
GROUP BY s0_.capability_id
) af
ON af.capability_id0=id;
我想要做的就是将 max(cnt) 作为额外的列。我知道您可以通过 cnt 订购并获得第一个,但我正在寻找替代方案。是否有可能或者我必须运行多个查询?