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!

Case statement in Where clause

SmithJohn45Feb 15 2022 — edited Feb 15 2022

currently using db 21c XE, required below for Oracle Apex app.
i have following data and want it to:

  1. if user enter like 'Cash' it should select bank_name like '%Cash%' (Cash Transaction) from here
  2. if not like 'Cash' then it should select bank_name where auto_dep_flag = 'Y'
    i tried Case in With clause but still failed, please help.
with bank_details as (Select 1 bank_id, 'First Bank' bank_name, 'N' auto_dep_flag from dual union all
           Select 2 bank_id, 'Deposit Bank' bank_name, 'Y' auto_dep_flag from dual union all
           Select 3 bank_id, 'Cash Transaction' bank_name, 'N' auto_dep_flag from dual
)
select bank_name from bank_details 

regards

This post has been answered by BEDE on Feb 15 2022
Jump to Answer
Comments
Post Details
Added on Feb 15 2022
4 comments
170 views