MySQL order by COUNT DISTINCT
SELECT
version,
COUNT(*) AS num
FROM
my_table
GROUP BY
version
ORDER BY
COUNT(*) DESC
SELECT version, COUNT(*) FROM tablename
GROUP BY version
ORDER BY COUNT(*) DESC;
or, alternate syntax
SELECT version, COUNT(*) FROM tablename
GROUP BY 1
ORDER BY 2 DESC;