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

mysql:ORDER BY Anzahl der Vorkommen eines Elements in einer Spalte der MySQL-Tabelle

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;