You can use group by
:
select favorite
from t
group by favorite
order by count(*) desc
fetch first 1 row only;
This is ANSI-standard sequence. Different databases have different ways of expressing the fetch first
clause.
In MS Access, this would be:
select top (1) favorite
from t
group by favorite
order by count(*) desc, username;
The inclusion of username
is to be sure that you only get one row in the event of ties.
2
solved How to Count The most common multiple event is SQL