Case Statement In a Where Clause.
797273Sep 11 2010 — edited Sep 13 2010OK, I need to find out if this is possible. Basically if it is the first day of the month, I need the code to look back to the prior month, else it should show the current month. I am getting errors ranging from missing the right parentheses to missing keyword. If there is a better way to do this, I am open to suggestions, I appreciate any and all help.
Select
Acct,
Completetion_Date
From TableName
Where Status = 'A'
And Completion_Date =
(Case
When To_char(sysdate,'dd') = '01' Then Completion_Date Between Add_Months(Trunc(Sysdate, 'MM'),-1) And Trunc(Sysdate,'MM')-1 --prior month
Else
Completion_Date Between Trunc(Sysdate, 'MM') And Add_Months(Trunc(Sysdate,'MM')-1,+1) --current month
End)
Thanks Brian
Edited by: user8698740 on Sep 11, 2010 6:16 PM