From: Michael Glaesemann <grzm@seespotcode.net>
To: Michael Glaesemann <grzm@seespotcode.net>
Cc: Joel Richard <postgres@joelrichard.com>
Cc: D'Arcy J.M. Cain <darcy@druid.net>
Cc: Claudia Kosny <ckosny@gmx.net>
Cc: sql pgsql <pgsql-sql@postgresql.org>
Subject: Re: fetch first rows of grouped data
Date: Mon, 27 Aug 2007 13:20:18 -0500
Message-ID: <56BD71D2-D761-4A80-9B3B-40CD7BF4BE8A@seespotcode.net> (raw)
In-Reply-To: <60F656A0-805D-4C3B-BCA5-742AC6C866E0@seespotcode.net>
References: <46D2FD9F.3020000@gmx.net>
<20070827125102.e52b43de.darcy@druid.net>
<4CB5D209-C0CC-466E-A967-E766D6AD799B@joelrichard.com>
<60F656A0-805D-4C3B-BCA5-742AC6C866E0@seespotcode.net>
On Aug 27, 2007, at 13:12 , Michael Glaesemann wrote:
> select city, event, event_date, (
> select count(event)
> from events i
> where i.city = o.city
> and i.event_date < o.event_date
> and event_date > current_date -- make sure they're future
> events
This should be i.event_date > current_date to be explicit.
> ) as nearness_rank
> from events o
> where event_date > current_date -- make sure they're future events
> having nearness_rank <= 1;
Michael Glaesemann
grzm seespotcode net
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: grzm@seespotcode.net, postgres@joelrichard.com, darcy@druid.net, ckosny@gmx.net
Subject: Re: fetch first rows of grouped data
In-Reply-To: <56BD71D2-D761-4A80-9B3B-40CD7BF4BE8A@seespotcode.net>
* 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