Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 16 Feb 2005 @ 16:31:30 GMT


     
  <Prev Next>  
<<First
<Prev
Next> Last>>  


Subj:   Null values in a select
 
From:   Anomy Anom

<-- Anonymously Posted: Wednesday, February 16, 2005 11:30 -->

We have two customer tables. cust_current and cust_prev.

Both tables used to have columns cust_id and cust_name. We are planning to add a new column alter_cust_id to both tables.

For the first time the column alter_cust_id would be null in the table cust_prev. The table cust_current will have a valid not null value for alter_cust_id.

I have expected the following delta logic query to give all the rows from cust_current. Since alter_cust_id is different in both tables.

     select cust_name, cust_id, Alter_cust_id
     from cust_current
     where
     (cust_name, cust_id, alter_cust_id) not in
     (select cust_name, cust_id, alter_cust_id from cust_prev);

But I got the same results as the following query. Here I am not selecting alter_cust_id in sub query.

     select cust_name, cust_id, Alter_cust_id
     from cust_current
     where
     (cust_name, cust_id) not in
     (select cust_name, cust_id from cust_prev);

I am surprised to see the result, as I thought NULL's have problems only while equating. Here it's simply ignoring the column alter_cust_id because it is null. Why?

I got the expected results when I replaced all the nulls with a space. the first query is selecting all the rows from cust_current table as the alter_cust_id has some value in current table and a space in prev table.



     
  <Prev Next>  
<<First
<Prev
Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023