Re: Fetching last n records from Posgresql - Mailing list pgsql-general

From John R Pierce
Subject Re: Fetching last n records from Posgresql
Date
Msg-id 56FB7B50.6070700@hogranch.com
Whole thread Raw
In response to Fetching last n records from Posgresql  ("Deole, Pushkar (Pushkar)" <pdeole@avaya.com>)
Responses Re: Fetching last n records from Posgresql
List 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

pgsql-general by date:

Previous
From: "Deole, Pushkar (Pushkar)"
Date:
Subject: Fetching last n records from Posgresql
Next
From: Alexander Reshetov
Date:
Subject: Missed LIMIT clause pushdown in FDW API