Home » SQL & PL/SQL » SQL & PL/SQL » Using Case in Where clause
Using Case in Where clause [message #239783] Wed, 23 May 2007 05:13 Go to next message
Messages: 5
Registered: March 2007
Junior Member
I am having a student table containing students attendance details. I want to get the attendance details of all the students for previous Friday,Saturday and Sunday if the given date is Monday and attendance details of all the Students for the previous day if the given day is between Tuesday to Friday i.e. details for Monday if the given date is a Tuesday. Can I use Case in Where clause for this?? anyone help me please.
The case statement i am using is:
case when to_char(SYSDATE,'DAY)='MONDAY' then Date_Time.Calendar_Date BETWEEN SYSDATE-3 AND SYSDATE-1 ELSE Date_Time.Calendar_Date=SYSDATE-1 END
but its giving an error "key work missing"
Re: Using Case in Where clause [message #239788 is a reply to message #239783] Wed, 23 May 2007 05:25 Go to previous message
Michel Cadot
Messages: 63937
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

trunc(Date_Time.Calendar_Date) between
case when to_char(SYSDATE,'DAY')='MONDAY' then trunc(SYSDATE-3) end
and trunc(sysdate-1)


Previous Topic: Differences
Next Topic: Easy update (but not for me:(
Goto Forum:

Current Time: Thu Oct 27 17:59:24 CDT 2016

Total time taken to generate the page: 0.08141 seconds