[英]max count together in an sql query
我在oracle db中有下表(简化):
productId | modelDescription
1 | thing
2 | another thing
3 | not a thing
4 | thing
我想选择在此表中具有最高外观的模型描述。 问题是可能存在几乎无限的模型描述。 所以结果集看起来像这样:
modelDescription | appearance
thing | 2
another thing | 1
... | ...
select modeldescription, count(modeldescription)
from products
group by modeldescription
order by 2 desc
此外,如果您只想要最高添加以下内容:
选择Top 1 modeldescription ......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.