Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 19 Jul 2005 @ 09:22:58 GMT


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


Subj:   COALESCE or CASE ?
 
From:   Joseph V D silva

I am doing a full outer join of two tables C & P (same columns) and inserting into a new table T (same columns again, plus and additional updatestatus column), I want to make sure that if a particular column in C is NULL then insert that column from P or use C.

This being my requirement should I go for COALESCE or CASE statment ?

ie use

     COALESCE (C.PKEY, P.PKEY)
     COALESCE (C.COL1, P.COL1)
     COALESCE (C.COL2, P.COL2)
     ...

or use

     CASE WHEN C.PKEY IS NULL THEN P.KEY ELSE C.PKEY END AS PKEY
     CASE WHEN C.COL1 IS NULL THEN  P.COL1 ELSE C.COL1 END AS COL1
     ...

All the columns in all tables are defined as NOT NULL. and the outer join is on the PKEY column ...

Any ideas as to how to get things going faster ?

Joe



     
  <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