Re: query problem
От | Jean-Luc Lachance |
---|---|
Тема | Re: query problem |
Дата | |
Msg-id | 3D6FCF6D.8E072AE0@nsd.ca обсуждение исходный текст |
Ответ на | query problem (Marco Muratori <marco.muratori@emaze.net>) |
Список | pgsql-sql |
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
В списке pgsql-sql по дате отправления: