hellouthere Posted March 30, 2007 Share Posted March 30, 2007 I am trying to find the modal value from a column in my database.... At he mo i have... $lstsql = "SELECT COUNT(`field`) AS `count` FROM table WHERE id='1' GROUP BY `field` ORDER BY `field` DESC LIMIT 1"; i got this from phpfreaks but it gives the amount of times the modal value occurs, not the actual value... any help is appreicciated... Quote Link to comment https://forums.phpfreaks.com/topic/44975-modal-value/ Share on other sites More sharing options...
fenway Posted April 4, 2007 Share Posted April 4, 2007 I'm confused -- modal value? Quote Link to comment https://forums.phpfreaks.com/topic/44975-modal-value/#findComment-221197 Share on other sites More sharing options...
hellouthere Posted April 22, 2007 Author Share Posted April 22, 2007 The modal value is the value that occurs most often in a set of records... 2,2,3,3,3,4,5,5,6,6,6,6,7,7 in the above set of results the modal value is 6 because it occurs most often (4 times) the result i am currently getting is 4 (the amount of times the value occurs) not 6 (the actual value) Quote Link to comment https://forums.phpfreaks.com/topic/44975-modal-value/#findComment-235319 Share on other sites More sharing options...
fenway Posted April 22, 2007 Share Posted April 22, 2007 Just ask for `field` back as well... Quote Link to comment https://forums.phpfreaks.com/topic/44975-modal-value/#findComment-235366 Share on other sites More sharing options...
bubblegum.anarchy Posted April 23, 2007 Share Posted April 23, 2007 and ORDER BY count DESC Quote Link to comment https://forums.phpfreaks.com/topic/44975-modal-value/#findComment-235639 Share on other sites More sharing options...
fenway Posted April 23, 2007 Share Posted April 23, 2007 and ORDER BY count DESC Sure, doesn't matter. Quote Link to comment https://forums.phpfreaks.com/topic/44975-modal-value/#findComment-235986 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.