Some times we will be facing issues in implementing logic for IF ELSE condition in WHERE CLAUSE in oracle query.
Below is the sample code which shows the work around for it by implementing OR in WHERE CLAUSE
Sample Query:
WITH TEMPTABLE AS (
SELECT EMPLOYEEID,EMPLOYEENAME,DEPARTMENTID
from EMPLOYEE
where EMPSAL=200000)
SELECT EMPLOYEENAME,EMPLOYEEID FROM TEMPTABLE WHERE EMPLOYEESTATUS=1 AND
(TEMPTABLE.DEPERTMENTID IS NULL or TEMPTABLE.EMPID > 0 AND
UPPER(TEMPTABLE.EMPLOYEENAME) LIKE UPPER('%TESTUSER%'));
No comments:
Post a Comment