pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Michael Sterling <stermic@gw.co.jackson.mo.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: max timestamp
Date: Sun, 15 Feb 2004 13:51:52 -0600
Message-ID: <20040215195152.GA570@wolff.to> (raw)
In-Reply-To: <f7359f44.0402101014.77198f7b@posting.google.com>
References: <f7359f44.0402101014.77198f7b@posting.google.com>

On Tue, Feb 10, 2004 at 10:14:04 -0800,
  Michael Sterling <stermic@gw.co.jackson.mo.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.



view thread (7+ messages)  latest in thread

Message-ID: <20040215195152.GA570@wolff.to>
Permalink:  ../20040215195152.GA570@wolff.to/
Also on:    postgresql.org/message-id/20040215195152.GA570@wolff.to

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bruno@wolff.to, stermic@gw.co.jackson.mo.us
  Subject: Re: max timestamp
  In-Reply-To: <20040215195152.GA570@wolff.to>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox