Re: query problem

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: query problem
Дата
Msg-id 200208291345.25680.josh@agliodbs.com
обсуждение исходный текст
Ответ на query problem  (Marco Muratori <marco.muratori@emaze.net>)
Список pgsql-sql
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 BerkusAglio Database SolutionsSan Francisco



В списке pgsql-sql по дате отправления:

Предыдущее
От: Marco Muratori
Дата:
Сообщение: query problem
Следующее
От: Jeff Boes
Дата:
Сообщение: Large number of lookups