|
|
Archives of the TeradataForum
Message Posted: Thu, 07 Jun 2012 @ 12:24:49 GMT
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
| |