Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 19-Dec-13 14:14pm
v2
Comments
[no name] 19-Dec-13 20:22pm    
To make it very clear: You are searching for MAX(Duplicate.ID_JOB), ID_MISTER does not count anyway?
joginder-banger 19-Dec-13 21:55pm    
what's you want's??

1 solution

try this.. if you want to get the highest, remove the top 1 if you just want to display their counts.
SQL
SELECT TOP 1
   COUNT(ID_JOB)
FROM YOURTABLE
GROUP BY ID_JOB
ORDER BY COUNT(ID_JOB) DESC	
 
Share this answer
 
Comments
[no name] 19-Dec-13 20:49pm    
Yep you got it 5.
ArunRajendra 19-Dec-13 22:25pm    
This is right but the need is to show the ID and not count. Can you modify the query.
Maciej Los 22-Dec-13 9:51am    
Is it so hard to modify it?
SELECT ID, COUNT(ID)
...
GROUP BY ID

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900