selecting the single most common value from a certain column?

This is a discussion on selecting the single most common value from a certain column? within the MySQL Database forums, part of the Database Forums category; Hi is there a way of selecting the single most common value from a certain column in a mysql table? ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-13-2007
Ciaran
 
Posts: n/a
Default selecting the single most common value from a certain column?

Hi is there a way of selecting the single most common value from a
certain column in a mysql table?

Thanks a lot,
Ciarán

Reply With Quote
  #2 (permalink)  
Old 03-13-2007
Paul Lautman
 
Posts: n/a
Default Re: selecting the single most common value from a certain column?

Ciaran wrote:
> Hi is there a way of selecting the single most common value from a
> certain column in a mysql table?
>
> Thanks a lot,
> Ciarán


SELECT column_name, count(*) as quantity
FROM table_name
GROUP BY column_name
ORDER BY quantity DESC
LIMIT 1


Reply With Quote
  #3 (permalink)  
Old 03-13-2007
Ciaran
 
Posts: n/a
Default Re: selecting the single most common value from a certain column?

Wow! I'm not sure what it means but it works great! Thanks a lot!

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:37 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0