sql case

Soluga
Soluga used Ask the Experts™
on
Hi,

I have the sql case statement below that works fine, however if the cn.disableReason is null then I want to return 'In-Active'

CASE candidateactive WHEN 1 THEN 'Active'  WHEN 0 THEN cn.disableReason  END  AS Status

Greatful for any help.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009

Commented:
CASE WHEN candidateactive  IS NULL THEN 'In-Active' WHEN candidateactive  = 1 THEN 'Active'  WHEN candidateactive  = 0 THEN cn.disableReason  END  AS Status

Author

Commented:
Thanks,
Problem is if there is a null value in cn.diablereason then it overwrites 'in-active' with Null
Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
Commented:
I see
CASE WHEN candidateactive  IS NULL THEN 'In-Active' WHEN candidateactive  = 1 THEN 'Active'  WHEN candidateactive  = 0 THEN ISNULL( cn.disableReason, 'In-Active')  END  AS Status

Open in new window

Author

Commented:
Excellent, thank very much.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial