SQL Where clause with case construct - TechRepublic
Question
May 20, 2013 at 02:33 PM
john.a.wills

SQL Where clause with case construct

by john.a.wills . Updated 13 years, 1 month ago

I have a very large query, with 10 tables and a lot of complex conditions. It is failing. I have sliced pieces off it until I am left with this:
select distinct perbarg_pidm “pidm”
from PERBARG
where CASE perbarg_barg_code = ‘A’
THEN
perbarg_bure_code = ‘&&Campus’
END
, which yields ERROR at line 3:
ORA-00920: invalid relational operator with a star under the P of perbarg;
or this:
select perbarg_pidm “pidm”
from PERBARG
where CASE (perbarg_barg_code = ‘A’)
THEN
perbarg_bure_code = ‘&&Campus’
END
, which yields ERROR at line 3:
ORA-00907: missing right parenthesis
with a star under the first equals sign.
I could obviously replace the present queries with something else and get it to work, but I do need this structure for the query from which I am deriving these. Where am I going wrong?

This discussion is locked

All Comments