mysql - How to Find ALL Most Common Values in SQL? -
mysql - How to Find ALL Most Common Values in SQL? -
how go showing all mutual values in sql?
so have query show mutual value here bellow.
select name, count(*) popularity cattwo grouping name order popularity desc limit 1; +----------+------------+ | name | popularity | +----------+------------+ | cat22610 | 7 | +----------+------------+
however, when display top 10 mutual value result ...
select name, count(*) popularity cattwo grouping name order popularity desc limit 10; +----------+------------+ | name | popularity | +----------+------------+ | cat22610 | 7 | | cat68704 | 7 | | cat14153 | 7 | | cat52476 | 7 | | cat4556 | 7 | | cat64173 | 7 | | cat5586 | 7 | | cat89302 | 6 | | cat97131 | 6 | | cat42010 | 6 | +----------+------------+
the goal display cats highest popularity. this.
+----------+------------+ | name | popularity | +----------+------------+ | cat22610 | 7 | | cat68704 | 7 | | cat14153 | 7 | | cat52476 | 7 | | cat4556 | 7 | | cat64173 | 7 | | cat5586 | 7 | +----------+------------+
help great. in advance.
i guess query help you!
select name, count(*) popularity cattwo grouping name having count(*) = ( select count(*) max_popularity cattwo grouping name order max_popularity desc limit 1 );
mysql sql count popularity
Comments
Post a Comment