Have a products table with item_id and color_id. I\'m trying to get the color_id with the most non-null instances.
This fails:
SELECT color_id
SELECT color_id, COUNT(color_id) AS occurances FROM so_test GROUP BY color_id ORDER BY occurances DESC LIMIT 0, 1
Here is a sample fiddle with a basic table that shows it working: sql fiddle