Re: [GENERAL] max() question

From: "Aaron J(dot) Seigo" <aaron(at)gtv(dot)ca>
To: Hitesh Patel <hitesh(at)presys(dot)com>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] max() question
Date: 1999-09-14 18:22:15
Message-ID: 99091412253102.03076@stilborne
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

--
Aaron J. Seigo
Sys Admin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Simms 1999-09-14 18:43:14 Re: [GENERAL] max() question
Previous Message Stéphane FILLON 1999-09-14 18:14:15 BUG with UNIQUE clause