|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
outputting the highest occurence in a column
I need to output which column value occurs the most
for example ProductID 1 1 1 2 2 2 2 3 3 Hence I should get 2 since that occurs the most. Please help. Thanks. -Shiraz |
|
#2
|
||||
|
||||
|
Code:
SELECT TOP 1 ProductID, count(ProductID) as thecount FROM table GROUP BY thecount ORDER BY thecount DESC Something like that should give you a row containing the top product and its count. The equivalent query (syntax slightly different) worked like a charm in mysql.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
Thanks
Thanks for the help
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > outputting the highest occurence in a column |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|