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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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