Re: Some insight on the proper SQL would be appreciated

Поиск
Список
Период
Сортировка
От Andy Colson
Тема Re: Some insight on the proper SQL would be appreciated
Дата
Msg-id 4C0E8437.2040801@squeakycode.net
обсуждение исходный текст
Ответ на Some insight on the proper SQL would be appreciated  (Aaron Burnett <aburnett@bzzagent.com>)
Список pgsql-general
On 6/8/2010 11:29 AM, Aaron Burnett wrote:
>
> Greetings,
>
> I hope this is the proper list for this, but I am a loss on how to achieve
> one particular set of results.
>
> I have a table which is a list of users who entered a contest. They can
> enter as many times as they want, but only 5 will count. So some users have
> one entry, some have as many as 15.
>


is it possible to add a new column:  "isValid integer"

(or something like it, to signify which one's can and cannot be selected)

I was thinking of doing it in two steps, an update to set isValid, then
a select with just "isValid = 1".  Not sure how hard the update would be
though.

Oh, wait, I'll bet a window function would be helpful... but you are on
8.2 so I dont think you have them.

I can think of a stored proc that might work, that ok?

Oh, another thought.. if we order it by username, signedup, and then did
something like:

where ... signedup > (select the 5th signedup from users ... )

not 100% how to do the subselect though.  I can see min(signedup) or
max(signedup), but not sure how to get the 5th.

Not real helpful, sorry, just some random thoughts

-Andy

В списке pgsql-general по дате отправления:

Предыдущее
От: "Francisco Figueiredo Jr."
Дата:
Сообщение: Re: Does npgsql have a bunch of bugs with DB enums?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: 3rd time is a charm.....right sibling is not next child crash.