Re: query help - Mailing list pgsql-novice

From Brendon Gleeson
Subject Re: query help
Date
Msg-id 44DAE0FB.3080805@gleesonprop.co.za
Whole thread Raw
In response to Re: query help  ("Jim C. Nasby" <jnasby@pervasive.com>)
Responses Re: query help  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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 by date:

Previous
From: Richard Broersma Jr
Date:
Subject: Re: ident authentication failed for user postgres.
Next
From: Tom Lane
Date:
Subject: Re: query help