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

Read great educational content like this and a lot more ! Create my free account now 🎁