Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

IF ELSE CONDITION IN SQL USING DECODE OR CASE

suman amaraJul 20 2020 — edited Jul 20 2020

Hi Team

i have a scenario like a region EMEA we need to show the data of EMEA if the user enters all then need to display full data in a table.

CREATE TABLE EMP_2(REGION VARCHAR2(22));

INSERT INTO EMP_2 VALUES('EMEA');

INSERT INTO EMP_2 VALUES('APJC');

INSERT INTO EMP_2 VALUES('AMERICAS');

---I try using decode not working

SELECT

  DECODE(REGION,'EMEA','EMEA','APJC','APJC','AMERICAS','AMERICAS','ALL') FROM EMP_2

WHERE

  DECODE(REGION,'EMEA','EMEA','APJC','APJC','AMERICAS','AMERICAS','ALL') = 'ALL'

;

can some give some idea on this..

Comments
Post Details
Added on Jul 20 2020
4 comments
1,298 views