Friday, September 26, 2014

Is this conditional WHERE clause possible?

Another option



SELECT ...
FROM ...
WHERE
Clause 1... AND
Clause 2... AND
(not @hasActualHours = 1 or Clause 3)
-- If @hasActualHours not 1 then the last condition is true, therefore it is like we did not use it
-- If @hasActualHours = 1 then you have to get true on the "Clause 3" condition





[Personal Site] [Blog] [Facebook]signature


No comments:

Post a Comment