Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 25 Aug 2006 @ 16:33:11 GMT


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


Subj:   Re: Weird Behaviour of SQL in Teradata
 
From:   Anomy Anom

<-- Anonymously Posted: Friday, August 25, 2006 11:26 -->

Did anyone check to see if the join columns contain null values? Null values can not be compare so they would drop out in join condition.

Some SQL writer will mistakenly use outer join to make up for this problem when they could just add another statement in their join condition to retain the data even if the column is null.

You can check to see whether or how many null values you have in the column with the following:

     Sel count(*)
     >From 
     Where  is null
     ;

You can retain the null values in the column with the following:

     Sel *
     >From  a
     Join  b
     Where (a.column1=b.column1
     Or (a.column1 is null
     And b.column1 is null))
     And (a.column2=b.column2
     Or (a.column2 is null
     And b.column2 is null))
     .....
     ;

If that is really what you want. Hope this helps.



     
  <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