dkilby
asked on
ms sql + a conditional where statement
Is it possible to have a conditional where statement if so how.
ie if a value in the select statement equals a something then the part of the where statement would equal one thing if not another
this is what i tried.
WHERE completed = 1
AND CASE WHEN touch_reason in (19,20) THEN
DATEDIFF(hour, cdol.maxdate , getDate()) > 12
ELSE
DATEDIFF(hour, cdol.maxdate , getDate()) > 0
END
ie if a value in the select statement equals a something then the part of the where statement would equal one thing if not another
this is what i tried.
WHERE completed = 1
AND CASE WHEN touch_reason in (19,20) THEN
DATEDIFF(hour, cdol.maxdate , getDate()) > 12
ELSE
DATEDIFF(hour, cdol.maxdate , getDate()) > 0
END
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
dkilby,
You're welcome :)
Regards,
Patrick
You're welcome :)
Regards,
Patrick
ASKER