Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 13 Oct 2004 @ 11:40:08 GMT


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


Subj:   Re: Can this query be written more efficient
 
From:   David Clough

Dunno if it's any more efficient - although I suspect it will be because we've been impressed with Left Joins with a 'Where Right Hand Table column is Null' in the past - but I suspect (without testing it) that this'll do the same thing:

     INSERT INTO table_copy
     SELECT tab1.* from
     table tab1
     left join (select X,Y from Mtable Group by X,Y) as mytab
     on mytab.X=tab1.X and mytab.Y=tab1.Y
     where mytab.X IS NULL
     ;insert into table_copy
     select *
     from Mtable;

     /*
     INSERT INTO table_copy
     SELECT *
     FROM table
     WHERE (X,Y) NOT IN (SELECT DISTINCT X,Y
                         FROM Mtable)
     ;insert into table_copy
     select *
     from Mtable;
     */

Dave Clough
Database Designer
Database Design Group



     
  <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