I've been recording the window height of users of my control panel.
I have a table like so:
user_id(INT) | window_height(INT)
--------------------------------
123 | 1200
124 | 1200
125 | 1100
126 | 1200
I have thousands of rows and would like to get the Modal averages.
ie 1200px = 300users, 1100px = 125users, 500px = 12users
I'm looking for a MySQL query i can just bang into PhpMyAdmin....
To get raw counts
To get the modal average (this will show multiple values if there are ties for the highest count)
This uses a MySQL trick of using a variable to store the max count as it goes through the aggregated subquery. Summary of operations