exclusive OR possible within a where clause? - Mailing list pgsql-general

From David Salisbury
Subject exclusive OR possible within a where clause?
Date
Msg-id 4E9777F2.9030303@globe.gov
Whole thread Raw
Responses Re: exclusive OR possible within a where clause?
List pgsql-general
I'm guessing that this isn't possible, but you guys are pretty smart. :)
Short version, is there a way to implement an exclusive OR in a where clause?

table1
dt1(timestamp)
---------
3 mins
5 mins
7 mins

table2
dt2(timestamp),   timedifference(interval)
---------------  ----------------------
4 mins              1 min ( always positive )

I want to join these two tables, grabbing the row from table 1 that
has a time equal to table2's record + interval, but table 2 could
have values that fall smack dab in the middle of two table1 records,
and I don't want both.

select
   t1.dt1
from
   table1 t1,
   table2 t2
where
   t2.dt2 + t2.timedifference = t1.dt1
     XOR ;-)
   t2.dt2 - t2.timedifference = t1.dt1

It's not important which of the two closest times
I get, but would like to get just one without being
messy.

Thanks for any ideas.  Maybe there's a great function out there
that solves this?

Dave










pgsql-general by date:

Previous
From: Anthony Presley
Date:
Subject: Re: Drill-downs and OLAP type data
Next
From: David Salisbury
Date:
Subject: Re: Error: timestamp with timezone + interval is not immutable while creating index