1

我在 oracle 数据库中有下表(简化):

productId  |  modelDescription 
         1 |             thing
         2 |     another thing
         3 |       not a thing
         4 |             thing

我想选择此表中出现次数最多的模型描述。问题是可能有几乎无限的模型描述。所以结果集应该是这样的:

modelDescription | appearance 
           thing |          2 
   another thing |          1 
             ... |        ...
4

2 回答 2

3
select modeldescription, count(modeldescription) 
from products 
group by modeldescription
order by 2 desc
于 2009-04-15T11:02:33.447 回答
1

此外,如果您只想要最高添加以下内容:

选择Top 1型号描述......

于 2009-04-15T11:12:03.000 回答