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