From: Josh Berkus <josh@agliodbs.com>
To: Marco Muratori <marco.muratori@emaze.net>
To: pgsql-sql@postgresql.org
Subject: Re: query problem
Date: Thu, 29 Aug 2002 13:45:25 -0700
Message-ID: <200208291345.25680.josh@agliodbs.com> (raw)
In-Reply-To: <Pine.LNX.4.30.0208301824330.25859-100000@marco.intranet>
References: <Pine.LNX.4.30.0208301824330.25859-100000@marco.intranet>
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
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: josh@agliodbs.com, marco.muratori@emaze.net
Subject: Re: query problem
In-Reply-To: <200208291345.25680.josh@agliodbs.com>
* 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