Jump to content

Modal Value


hellouthere

Recommended Posts

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...

Link to comment
https://forums.phpfreaks.com/topic/44975-modal-value/
Share on other sites

  • 3 weeks later...

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)

Link to comment
https://forums.phpfreaks.com/topic/44975-modal-value/#findComment-235319
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.