Re: Retrieving Data from table based on Date and Time.

From: Stephen Cook <sclists(at)gmail(dot)com>
To: VENKTESH GUTTEDAR <venkteshguttedar(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Re: Retrieving Data from table based on Date and Time.
Date: 2014-11-01 08:39:29
Message-ID: 54549C41.1050001@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/1/2014 2:27 AM, VENKTESH GUTTEDAR wrote:
> I have a table in which i have some few fields, in that few, one
> field is of date type and second one is of time data type, so now my
> question is how can i fetch the data with latest date and time, or the
> last inserted value from the PostgreSQL Table.?

SELECT *
FROM mytable
ORDER BY datecolumn DESC,
timecolumn DESC
LIMIT 1;

You might want to put an index on them.

-- Stephen

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message VENKTESH GUTTEDAR 2014-11-01 11:13:05 Re: Retrieving Data from table based on Date and Time.
Previous Message VENKTESH GUTTEDAR 2014-11-01 06:27:03 Retrieving Data from table based on Date and Time.