Re: select max()

Поиск
Список
Период
Сортировка
От Alexander Farber
Тема Re: select max()
Дата
Msg-id AANLkTimoJoDokTX5wyHA6HQ0W7_enCjm4s+0kc8Uaus7@mail.gmail.com
обсуждение исходный текст
Ответ на select max()  (Alexander Farber <alexander.farber@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: "Andrus"
Дата:
Сообщение: how to increase upsize speed
Следующее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: PostgreSQL hanging on new connections?