If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Unanswered: Decode Statement Within Where Clause?

Is it possible to do a Decode statement within a Where clause? I'm trying to write SQL that will pull the Branch code from 2 different tables. If it's Null within the Trx table then pull from the Sales table.
I tried doing an Or clause such as below, but it pulls double if it's in both tables for 1 request.

I'd be happier if you posted some more relevant information (for example, Oracle database version, CREATE TABLE and INSERT INTO sample data statements) so that it would be easier to do it for you.

Now I tried to create a *working* query which might server as an example for you - see if it suits your needs and, if so, try to implement it into your case. The general idea is what you wanted - the only difference is using the CASE instead of DECODE.