Re: select max() - Mailing list pgsql-general

From Alexander Farber
Subject Re: select max()
Date
Msg-id AANLkTimoJoDokTX5wyHA6HQ0W7_enCjm4s+0kc8Uaus7@mail.gmail.com
Whole thread Raw
In response to select max()  (Alexander Farber <alexander.farber@gmail.com>)
List pgsql-general
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

pgsql-general by date:

Previous
From: "Andrus"
Date:
Subject: how to increase upsize speed
Next
From: hubert depesz lubaczewski
Date:
Subject: Re: PostgreSQL hanging on new connections?