Sekarang bahkan lebih sederhana:PostgreSQL 9.4 memperkenalkan mode()
fungsi:
select mode() within group (order by food_id)
from munch
group by country
kembali (seperti contoh user2247323):
country | mode
--------------
GB | 3
US | 1
Lihat dokumentasi di sini:https://wiki.postgresql.org/wiki/Aggregate_Mode
https://www.postgresql.org/docs/current/static/functions-aggregate.html#FUNCTIONS-ORDEREDSET-TABLE