Re: query help

From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: Brendon Gleeson <brendon(at)gleesonprop(dot)co(dot)za>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: query help
Date: 2006-08-09 22:49:34
Message-ID: 20060809224934.GD27928@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Wed, Jul 26, 2006 at 01:37:05PM +0200, Brendon Gleeson wrote:
>
> I have a table called "marketing_campaigns":
>
> marketing_campaigns:
> +----+--------------+------------+-------------+-------------
> | id | date_started | date_ended | property_id | status
> +----+--------------+------------+-------------+-------------
> | 1 | 2005-01-01 | 2005-03-12 | 5 | sold
> | 2 | 2006-01-11 | 2006-02-23 | 5 | jointly sold
> | 3 | 2006-05-13 | NULL | 5 | for sale
> | 4 | 2006-02-01 | 2006-02-06 | 6 | sold
>
> I am having trouble trying to say: Only show old campaigns And only if
> their is not a "current" campaign for this property(property_id)

#define 'old campaigns' and 'current'

> The result of the query should only return row 4. Is their a way to do this
> in sql without resorting to proprietary functions, or should I resort to
> using Ruby (rails app)

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.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

In response to

  • query help at 2006-07-26 11:37:05 from Brendon Gleeson

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jim C. Nasby 2006-08-09 22:53:27 Re: select from pg_trigger
Previous Message Garcia, Joshua 2006-08-09 17:05:33 select from pg_trigger