Re: max timestamp

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Michael Sterling <stermic(at)gw(dot)co(dot)jackson(dot)mo(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: max timestamp
Date: 2004-02-15 19:51:52
Message-ID: 20040215195152.GA570@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, Feb 10, 2004 at 10:14:04 -0800,
Michael Sterling <stermic(at)gw(dot)co(dot)jackson(dot)mo(dot)us> wrote:
> i'm trying to get the max time stamp, from each day, of a range of
> dates, not just the max time stamp for the complete range dates but
> for each day.

SELECT DISTINCT ON can probably do what you want. Something like:
SELECT DISTINCT ON (timestamp::DATE) * FROM table ORDER BY timestamp DESC;

This won't produce any records for days where there are no timestamps.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tomasz Myrta 2004-02-15 19:53:44 Re: writing a dynamic sql
Previous Message Stephan Szabo 2004-02-15 19:36:45 Re: Function