From: | Alexander Farber <alexander(dot)farber(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | select max() |
Date: | 2010-11-30 09:28:36 |
Message-ID: | AANLkTinRgyY0LdRvqN7sywqO60s+gKkmyJMOJSYiB2Gj@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
I have this table where I store player results for each week:
# select * from pref_money limit 5;
id | money | yw
----------------+-------+---------
OK32378280203 | -27 | 2010-44
OK274037315447 | -56 | 2010-44
OK19644992852 | 8 | 2010-44
OK21807961329 | 114 | 2010-44
FB1845091917 | 774 | 2010-44
(5 rows)
I'm trying to find the winners for each week and
also how many times the player has won,
so that I can display a number of medals
at his or her profile page.
I'm trying:
# select id, money from pref_money where money in
(select max(money) from pref_money group by yw);
id | money
----------------+-------
DE8048 | 3927
VK91770810 | 6133
DE7115 | 6655
OK252342810632 | 8053
OK228530000997 | 1013
(5 rows)
But I'm worried that "where in" will return false positives
(for the cases with the same money values)
and also I don't know how to count the repeated winners?
Thank you
Alex
From | Date | Subject | |
---|---|---|---|
Next Message | Dusan Misic | 2010-11-30 09:37:53 | Re: PostgreSQL hanging on new connections? |
Previous Message | Craig Ringer | 2010-11-30 09:20:59 | Re: PostgreSQL hanging on new connections? |