Case function with IS Null

How do I implement such scenario in Teradata

If Col1 is null or if Col1 = ''Jack'' then Col2 else Col1

I ha e implemented it but for some reason it's not working may be some issue with Bracketay

2 Answers

You can also use the NULLIF() operator:

COALESCE(NULLIF(col1,'Jack'), col2) 

This is logically equivalent to the CASE statement in the previous answer.

1

You can use a case expression:

case when col1 is null or col1 = 'Jack' then col2 else col1
end

String (varchar) constants need to be enclosed in sinqle quotes in SQL.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like