簡體   English   中英

在SQL查詢中最大計數

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM