Re: query help

From: Brendon Gleeson <brendon(at)gleesonprop(dot)co(dot)za>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: query help
Date: 2006-08-10 07:32:11
Message-ID: 44DAE0FB.3080805@gleesonprop.co.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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..

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Walid Haider 2006-08-10 13:10:00 Unable to connect to PostgreSQL 8 from PGAdmin III
Previous Message Richard Broersma Jr 2006-08-10 05:04:42 Re: ident authentication failed for user postgres.