Re: Last x records

From: "Richard Huxton" <dev(at)archonet(dot)com>
To: <pgsql-general(at)postgresql(dot)org>, "Matthias Teege" <matthias(at)mteege(dot)de>
Subject: Re: Last x records
Date: 2001-02-27 12:25:15
Message-ID: 003301c0a0b8$57984f00$1001a8c0@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

From: "Matthias Teege" <matthias(at)mteege(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Richardson 2001-02-27 12:30:31 Re: Problems with RAISE EXCEPTION
Previous Message Steffen Emil Thorkildsen 2001-02-27 12:25:07 Query precompilation?