phpMyAdmin
 sql >> Database >  >> Database Tools >> phpMyAdmin

mysql:ORDER BY numero di occorrenze di un elemento in una colonna della tabella mysql

SELECT x.* 
  FROM my_table x 
  JOIN (SELECT location, COUNT(*) total FROM my_table GROUP BY location) y
    ON y.location = x.location
 ORDER 
    BY total DESC
     , id;