Re: [GENERAL] Fetching last n records from Posgresql

2016-03-30 Thread Francisco Olarte
Hi Pushkar: On Wed, Mar 30, 2016 at 8:40 AM, Deole, Pushkar (Pushkar) wrote: > Does PostgreSQL support a query to fetch last ‘n’ records that match the > selection criteria. I am trying to fetch records from a table with start > date that falls in last 30 days, however, I want to fetch the oldest

Re: [GENERAL] Fetching last n records from Posgresql

2016-03-30 Thread Sándor Daku
> sorting through the application.. > > > > *From:* pgsql-general-ow...@postgresql.org [mailto: > pgsql-general-ow...@postgresql.org] *On Behalf Of *Moreno Andreo > *Sent:* Wednesday, March 30, 2016 3:03 PM > *To:* pgsql-general@postgresql.org > *Subject:* Re: [GENERAL] Fe

Re: [GENERAL] Fetching last n records from Posgresql

2016-03-30 Thread Moreno Andreo
] On Behalf Of Moreno Andreo Sent: Wednesday, March 30, 2016 3:03 PM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] Fetching last n records from Posgresql   Il 30/03/2016

Re: [GENERAL] Fetching last n records from Posgresql

2016-03-30 Thread Deole, Pushkar (Pushkar)
[mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Moreno Andreo Sent: Wednesday, March 30, 2016 3:03 PM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] Fetching last n records from Posgresql Il 30/03/2016 11:19, Deole, Pushkar (Pushkar) ha scritto: select * from t order by

Re: [GENERAL] Fetching last n records from Posgresql

2016-03-30 Thread Moreno Andreo
Il 30/03/2016 11:19, Deole, Pushkar (Pushkar) ha scritto: select * from t order by record_date desc limit 5;   this will return the recent 5 records.. what I want is the oldest 5 records (in last 30 d

Re: [GENERAL] Fetching last n records from Posgresql

2016-03-30 Thread Sándor Daku
rg [mailto: > pgsql-general-ow...@postgresql.org] *On Behalf Of *John R Pierce > *Sent:* Wednesday, March 30, 2016 12:38 PM > *To:* pgsql-general@postgresql.org > *Subject:* Re: [GENERAL] Fetching last n records from Posgresql > > > > On 3/29/2016 11:40 PM, Deole, Pushkar (Pus

Re: [GENERAL] Fetching last n records from Posgresql

2016-03-30 Thread Deole, Pushkar (Pushkar)
PM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] Fetching last n records from Posgresql 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

Re: [GENERAL] Fetching last n records from Posgresql

2016-03-30 Thread John R Pierce
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 pier

[GENERAL] Fetching last n records from Posgresql

2016-03-29 Thread Deole, Pushkar (Pushkar)
Hi, Does PostgreSQL support a query to fetch last 'n' records that match the selection criteria. I am trying to fetch records from a table with start date that falls in last 30 days, however, I want to fetch the oldest 'n' records and not the recent ones. I know there is a LIMIT clause which I