Re: Fetching last n records from Posgresql

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Fetching last n records from Posgresql
Date: 2016-03-30 07:08:00
Message-ID: 56FB7B50.6070700@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 3/29/2016 11:40 PM, Deole, Pushkar (Pushkar) wrote:
>
> WITH t AS (
>
> SELECT * FROM mytable ORDER BY record_date ASC LIMIT 5
>
> )
>
> SELECT * FROM t ORDER BY record_date DESC;
>

why do it twice when you can just do....

select * from t order by record_date desc limit 5;

--
john r pierce, recycling bits in santa cruz

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Reshetov 2016-03-30 08:52:10 Missed LIMIT clause pushdown in FDW API
Previous Message Deole, Pushkar (Pushkar) 2016-03-30 06:40:42 Fetching last n records from Posgresql