SQL - CASE STATEMENT (EXPRESSION)
Posted on 2007-10-01
My question today is the correct way to write a case statement (expression)
I have written as follows:
CASE WHEN :1='bbbbb' THEN B. DEPTID = 50000,563000,56400,56450,56500,58400
ELSE CASE WHEN :1= 'aaaaa' THEN B. DEPTID= 41000,55300,53001,55303,56900,57200,57220,57500,58000,41500
The:1 is a prompt that the user enters to run the query, then depending on the usernumber the query only runs data for specified departments .
So to be clear - if usernumber = aaaaa then run only departments 410000, 530001, etc.
Thank for your help,