-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of David Salisbury
Sent: Monday, October 17, 2011 3:41 PM
To: John R Pierce
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] exclusive OR possible within a where clause?
Perhaps what I'm hoping to do got munged. In essence it's equivalent of..
create table test ( something numeric ); insert into test values ( 1 );
insert into test values ( 2 );
select * from test where ( something = 1.5 + .5 ) or ( something = 1.5 - .5
);
something
-----------
1
2
(2 rows)
select * from test where ( something = 1.5 + .5 ) <> ( something = 1.5 - .5
);
something
-----------
1
2
(2 rows)
( which is of course equivalent of where something = 1 or something = 2 )
In my fabled XOR, I'd get the first one it matched, say something = 1, and
the something = 2 would then be ignored/dropped.
----------------------------------------------------------------------------
-------------
1) There is no concept of "FIRST" since you failed to include an ORDER BY
clause
2) Given that "something" can only take on a single value comparing it
against two separate (and different) values renders the difference between
OR and XOR meaningless.
If you want good help you need to give good examples - preferably real ones.
What you are trying to do has NOTHING to do with XOR. Provide a more
informative description of WHAT you are trying to do and additional REAL
sample data. From what you've described here, though, you probably want to
use WINDOW functions (RANK/ROW_NUMBER) in a sub-query and then look for only
those rows with RANK/ROW_NUMBER equal to 1.
David J.
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make
changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general