Re: [GENERAL] max() question - Mailing list pgsql-general

From Michael Simms
Subject Re: [GENERAL] max() question
Date
Msg-id 199909141843.TAA10165@argh.demon.co.uk
Whole thread Raw
In response to Re: [GENERAL] max() question  ("Aaron J. Seigo" <aaron@gtv.ca>)
List pgsql-general
>
> On Tue, 14 Sep 1999, you wrote:
> > I have a table with and email address and a datetime timestamp.  What
> > would be the easiest way to select the 3 earliest timestamps (earliest
> > being furthest in the past from the current date)
>
> lots of ways =) though the first that comes to mind is the use of cursors.
> order by DATEFIELD asc and just grab the first three.. or if that don't work for
> ya (for whatever reason)... you could select the min(DATEFIELD), then select the
> min(DATEFIELD) where DATEFIELD > (that last select's return), then again for
> the third... this is convoluted, but if you are doing this over a network, a
> cursor may not be the easiest thing to implement, depending on what you are
> using. as for performance of this? i dunno. cursor would be best.

Hows about:

select * from table order by timestamp limit 3

That should do it

                    ~Michael

pgsql-general by date:

Previous
From: "Aaron J. Seigo"
Date:
Subject: Re: [GENERAL] max() question
Next
From: "amy cheng"
Date:
Subject: Re: [GENERAL] shutdown gracefully & single user mode?