Re: returning only part of a rule set

From: Dave Potts <dave(dot)potts(at)pinan(dot)co(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: returning only part of a rule set
Date: 2014-11-25 22:56:14
Message-ID: 5475090E.6090304@pinan.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 25/11/14 22:24, David G Johnston wrote:

Thanks List, I think this is the right way to go.

> Adrian Klaver-4 wrote
>>> If I am only interested in get 2 entries per result set, I would expect
>>> to see
>> Actually <=2.
>> How do you determine which rows to keep, by id or something else?
>>
>>> 1 xx,yy
>>> 2 xx,yy
>>>
>>>
>>> 1,dd,zz
>>> 2,dd,zz
>>>
>>> 1, ee,ff
>>>
>>> Using LIMIT only gives
>>> 1 xx,yy
>>> 2 xx,yy
>>>
>>> Sorry for not explaining it very, I want to limit the size of an
>>> inviduail set of records which is part of set of records.
>> It would help if we could see the actual query you are using to get the
>> result sets, suitably anonymized if needed.
> The general answer is that you use a window clause and a row_number()
> function over an appropriate partiton. Put that in a subquery then in the
> outer query add a where clause for row_number <= 2.
>
> David J.
>
>
>
>
>
>
> --
> View this message in context: http://postgresql.nabble.com/returning-only-part-of-a-rule-set-tp5828217p5828226.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2014-11-25 23:35:52 Re: SQL functions and triggers?
Previous Message David G Johnston 2014-11-25 22:24:57 Re: returning only part of a rule set