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!

Can I use a 'CASE' statement in a 'WHERE' clause?

514255Jan 21 2009 — edited Jan 28 2009
I'm trying to do this:

select ('fields')
from ('tables')
where (case when (:p_note_date='week')
then vmen.note_date between (trunc(sysdate,'day') and trunc(sysdate,'day')+6)
when (:p_note_date='month')
then vmen.note_date between (trunc(sysdate,'month') and last_day(sysdate))
else vmen.note_date between :p_start_date and :p_end_date
end)

I keep getting errors. Can't we use a 'CASE' statement in a 'WHERE' clause? I've tried using 'DECODE' and it's not working either.

Thanks!!
Kris
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 25 2009
Added on Jan 21 2009
15 comments
950 views