Teradata: How to compare potentially null fields without using coalesce?

Scenario: 

When we are comparing two null fields, the result is always a fail. Lets see how to handle such scenarios.

  • Null <> Null (Null is never equal to Null)
  • Null <> ''
  • Null <> 0

Solution:

We are using a query that uses coalesce to compare potentially null values. it does make queries more difficult to maintain, it's flat out ugly. but cant help it:

where coalesce(tbl1.field,'~') <> Coalesce(tbl2.field,'~')

nVector

posted on 19 May 18

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds