SQL选择具有最大重复数的列值 [英] SQL select column value with biggest number of duplicates
本文介绍了SQL选择具有最大重复数的列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到了一个似乎无法解决的问题。我有一个如下所示的数据表:
示例: http://i.stack.imgur.com/tbKEk.png
我需要选择最重复的ID_JOB值。在这个特定的例子中,它将是ID_JOB = 1.
I am having a problem I can't seem to solve. I have a data table that looks like this:
Example: http://i.stack.imgur.com/tbKEk.png
I need to select the ID_JOB value which is duplicated the most. In this particular example it would be ID_JOB = 1.
推荐答案
试试这个..如果你想得到最高,如果你只想显示,删除前1他们的计数。
try this.. if you want to get the highest, remove the top 1 if you just want to display their counts.
SELECT TOP 1
COUNT(ID_JOB)
FROM YOURTABLE
GROUP BY ID_JOB
ORDER BY COUNT(ID_JOB) DESC
这篇关于SQL选择具有最大重复数的列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文