Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 07 Jun 2012 @ 12:24:49 GMT


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


Subj:   Re: Tables Data comparison
 
From:   Dsouza, Irwing

This is a Query I've used a lot when comparing 2 tables:

weblogs.sqlteam.com/...


     SELECT MIN(TableName) as TableName, ID, COL1, COL2, COL3 ...
     FROM
     (
       SELECT 'Table A' as TableName, A.ID, A.COL1, A.COL2, A.COL3, ...
       FROM A
       UNION ALL
       SELECT 'Table B' as TableName, B.ID, B.COL1, B.COl2, B.COL3, ...
       FROM B
     ) tmp
     GROUP BY ID, COL1, COL2, COL3 ...
     HAVING COUNT(*) = 1
     ORDER BY ID


     
  <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