mysql - Display the Object with the most equal entries -
hi want display country(land in german) haves museums.
my table looks like:
+-----------+----------------------+-------------------+--------------------------+---------------+ | museumsnr | name | stadt | land | hauptstadt | +-----------+----------------------+-------------------+--------------------------+---------------+ | 1 | museum of modern art | new york | united states of america | washington dc | | 2 | kunstmuseum | bern | schweiz | bern | | 3 | musée picasso | paris | frankreich | paris | | 4 | städel | frankfurt main | deutschland | berlin | | 5 | museum ludwig | köln | deutschland | berlin | +-----------+----------------------+-------------------+--------------------------+---------------+
so desired output should be:
+--------------------------+------+ | land |anzahl| +--------------------------+------+ | deutschland | 2 | +--------------------------+------+
this i´ve tried:
select land, count(name) name museum order name desc;
the output:
+--------------------------+------+ | land | name | +--------------------------+------+ | united states of america | 5 | +--------------------------+------+
thanks in advance help!
select land, count(*) anzahl yourtable group land order anzahl desc limit 1;`
only tested in postgresql, should close enough in mysql.
Comments
Post a Comment