Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8942685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:34:32+00:00 2026-06-15T11:34:32+00:00

In any database, it appears to be a common practice to use coalesce() to

  • 0

In any database, it appears to be a common practice to use coalesce() to compare nullable fields for equality. For example, if you’re comparing two nullable string fields, you would use where coalesce(tbl1.stringfield,'') = coalesce(tbl2.stringfield,''). This works because the empty string of '' converts very well contextually to null.

However, what if you’re dealing with datatypes like dates or numbers that don’t have an “empty” equivalent? In Teradata, if you try where coalesce(tbl1.numberfield,'') = coalesce(tbl2.numberfield,''), you get a datatype mismatch error if one of the fields is not null. This is because it tries to compare a number to an empty string. To get it to work, you have to use where coalesce(tbl1.numberfield,0) = coalesce(tbl2.numberfield,0). However, what if tbl1.numberfield is null and tbl2.numberfield actually contains the value of 0? That WHERE condition would return true when, in reality, it should return false since one value is null and the other is 0. The only way around this that I can see is this very clunky case logic:

where case
    when 
        (tbl1.numberfield is null and tbl2.numberfield is null) or
        (tbl1.numberfield is not null and tbl2.numberfield is not null) or
        tbl1.numberfield <> tbl2.numberfield
    then 1
    else 0
end = 1

And to think that all this could be avoided if comparing two nulls with a simple equal sign were permitted.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:34:33+00:00Added an answer on June 15, 2026 at 11:34 am

    Why not just

    SELECT * FROM TABLE A, TABLE2 B WHERE A.a = B.a or ( A.a is NULL and b.A is NULL)
    

    This is the standard for checking equity on null-able fields that i am familiar with and it should work in all cases. Its more straight forward for the reader and should run faster.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems that MSMQ doesn't use any Database management system to manage messages. How
There's a Rails 3.2.3 web application which doesn't use any database. But in spite
Please any on tell me can i use Sqlite database in my Windows Phone
While opening any MS Access database, a security warning appears saying that the file
Suppose I am designing a class that can handle any database technology to create
I need a database for testing a data masking solution. Any database would do
Basically I need to connect to the database without any existing databases. In SQL,
I would like to find out if any and which database links are being
Any short code to get the database table prefix in cakephp controller action ?
Our database currently doesn't define primary keys on any tables. All of the id

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.