pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jean-Luc Lachance <jllachan@nsd.ca>
To: josh@agliodbs.com
Cc: Marco Muratori <marco.muratori@emaze.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: query problem
Date: Fri, 30 Aug 2002 16:02:53 -0400
Message-ID: <3D6FCF6D.8E072AE0@nsd.ca> (raw)
References: <Pine.LNX.4.30.0208301824330.25859-100000@marco.intranet>
	<200208291345.25680.josh@agliodbs.com>

I think you meant min(date)...


Josh Berkus wrote:
> 
> Marco,
> 
> > Is there a way to obtain this records by performing one
> > single query and not by making for each city something like
> > "SELECT city,date FROM table WHERE city='London' AND date>'2002-07-19
> > 15:39:15+00' ORDER BY date ASC LIMIT 1;"?
> 
> Close.  Try:
> 
> SELECT city, MAX("date") as last_date
> FROM table
> WHERE "date" > $date
> GROUP BY city
> ORDER BY city
> 
> Though as an aggregate query, this will be slow on large tables.
> 
> --
> -Josh Berkus
>  Aglio Database Solutions
>  San Francisco
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org



view thread (17+ messages)  latest in thread

Message-ID: <3D6FCF6D.8E072AE0@nsd.ca>
Permalink:  ../3D6FCF6D.8E072AE0@nsd.ca/
Also on:    postgresql.org/message-id/3D6FCF6D.8E072AE0@nsd.ca

 · 

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: jllachan@nsd.ca, josh@agliodbs.com, marco.muratori@emaze.net
  Subject: Re: query problem
  In-Reply-To: <3D6FCF6D.8E072AE0@nsd.ca>

* 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