Ok, it is # select id from pref_money where money in (select max(money) from pref_money group by yw); id ---------------- DE8048 VK91770810 DE7115 OK252342810632 OK228530000997 (5 rows) And to see how many times a player has won is: # select count(id) from pref_money where id='DE7115' and money in (select max(money) from pref_money group by yw); count ------- 1 (1 row) My only problem is how to prevent false positives, when the money value in 2 months is the same and in 1 of the months it is the max value, but in the other month it is not the max value and has another id. Then the latter id will be falsely indicated as "winner"... Regards Alex -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general