19 May 2018 · npac ·       Add to Favorites   Report

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


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


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,'~')


posted on 19 May 2018

Read great educational content like this and a lot more !

Members get free exclusive access to content, new courses, and discounts. Signup for a free account to write a post / comment / upvote posts. Creating an account takes less than 5 seconds and you can start earning badges & points too