Re: Last x records - Mailing list pgsql-general

From Richard Huxton
Subject Re: Last x records
Date
Msg-id 003301c0a0b8$57984f00$1001a8c0@archonet.com
Whole thread Raw
In response to Last x records  (Matthias Teege <matthias@mteege.de>)
Responses Re: Last x records
List pgsql-general
From: "Matthias Teege" <matthias@mteege.de>

> Moin,
>
> is there any way to get the last x records of an query
> result?
>
> I can use "... order by x DESC LIMIT n" but I need ASC not
> DESC, the last records in the correct order.

If you know how many records there are you could use "LIMIT n OFFSET m"
where m = number of records - n

Otherwise, the only thing that I can think of is to set up a view that does
the LIMIT n on a DESC then sort ASC when selecting on that view - might
work.

- Richard Huxton


pgsql-general by date:

Previous
From: brichard@cafod.org.uk (Bruce Richardson)
Date:
Subject: Re: Problems with RAISE EXCEPTION
Next
From: "Mark, Terry"
Date:
Subject: RE: copying tables