How To Do A Count In SQL Of THe Most Common Item

Noob2008

New member
Local time
Tomorrow, 04:47
Joined
Nov 3, 2009
Messages
5
Hi ,

I Have A database table call Department . In this table imagine this , everyday i have to enter a department for a month . Department i enter can have repeated entires (For examples : there can be 1 or more particular department in a month)

Department <---- Column Name
Logistics
F&B
Administrator
Logistics
Logistics
ETC .... till 30 records ( Taking into account that particular month has 30 days )

Now my Q is is there a SQL statement in which i can run it and it will count and tell me which is the department that has the most re-Occurance ?

In my example above it shld returm Logistics as it appear 3 times .

Kindly Advise . Thanks
 
Try this untested SQL

SELECT Top 1 Department, Count(Department) AS HowMany
FROM TableName
GROUP BY Department
ORDER BY Count(Department) DESC;
 
Great ! It Works Nice .

Thanks ! Much ! :) :p:p
 
No problemo, and welcome to the site by the way!
 

Users who are viewing this thread

Back
Top Bottom