0

I'm having trouble using Case statement for multiple criteria, I don't know how to nest another CASE.

  • DateTime column: Control_OpenDateOwner
  • DateTime column: Control_ClosedDateRev

Computed column:

(case when [Control_ClosedDateRev] IS NULL then '1' else '0' end)

Trying to I want to calculate when the OPENDATE is greater than 4 Days opened (using today()) and the close date is Null, put a 1 (open record and has more than 4 days opened or 0 if the record is closed or less than 4 days opened, I can't get it to work.

Note: I'm not expert on SQL, beginner. Tried this post but its kind of confusing for me. (Best way to do nested case statement logic in SQL Server)

Thank you

Community
  • 1
  • 1
Eddy V
  • 99
  • 4
  • 15

1 Answers1

1

You can use AND in a CASE statement. You don't need to perform a true nested CASE statement in this scenario

(CASE WHEN [Control_ClosedDateRev] IS NULL AND DateDiff(day,opendate,getDate()) > 4 THEN '1' ELSE '0' END)
Matt Busche
  • 13,789
  • 5
  • 34
  • 58