Re: query help

Поиск
Список
Период
Сортировка
От Brendon Gleeson
Тема Re: query help
Дата
Msg-id 44DAE0FB.3080805@gleesonprop.co.za
обсуждение исходный текст
Ответ на Re: query help  ("Jim C. Nasby" <jnasby@pervasive.com>)
Ответы Re: query help  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Jim C. Nasby wrote:
...
> No, this can certainly be done in SQL, though if you have pseudo or ruby
> code on how you'd do it, it might make it a bit more clear on what
> you're after.
...
I managed to find a suitable solution for this:
(I am using postgres 7.4)

SELECT property_id, address FROM marketing_campaigns
LEFT JOIN properties ON properties.id = marketing_campaigns.property_id
WHERE address LIKE *?
GROUP BY property_id, address
HAVING count(ended_on) = **count(1)

* variable
** apparently count(1) is faster  than count(*) and count(id), my Rails log
confirms this, however I have a limited amount of records at the moment so
benchmarks are properly inaccurate..

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

Предыдущее
От: Richard Broersma Jr
Дата:
Сообщение: Re: ident authentication failed for user postgres.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: query help