SQL query build where clause using case statement
Posted on 2014-02-21
I have a query and I would like to build my where clause using a case statement but must be missing something because my syntax isn't correct. I want to build my where clause based on a parameter (radio button value) that is selected by the user. My statement is below. Thanks for your help.
SELECT COL1, COL2, COL3, COL4, COL5, COL6, COL7, COL8, COL9, COL10
THEN 'MYID = :P1_CHOICE1'
THEN 'MY2NDFIELD = :P1_CHOICE2'
THEN 'MY3RDFIELD = :P1_CHOICE3'
THEN 'MYFOURTHFIELD = :P1_CHOICE4'
THEN 'MYFIFTHFIELD = :P1_CHOICE5'
THEN 'MYSIXTHFIELD = :P1_CHOICE6'
THEN '(MYDATE >= TO_DATE(:P1_DATE, 'MM/DD/YYYY')'
order by MYDATE)