Skip site navigation (1) Skip section navigation (2)

query help

From: Brendon Gleeson <brendon(at)gleesonprop(dot)co(dot)za>
To: pgsql-novice(at)postgresql(dot)org
Subject: query help
Date: 2006-07-26 11:37:05
Message-ID: 44C753E1.1020708@gleesonprop.co.za (view raw or flat)
Thread:
Lists: pgsql-novice
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)

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)

Responses

pgsql-novice by date

Next:From: Hal DavisonDate: 2006-07-26 12:02:48
Subject: Lurking Wanna Be
Previous:From: Richard Broersma JrDate: 2006-07-26 11:28:09
Subject: Fwd: Re: Installation "baby" steps (next steps)?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group