Reputation: 2977
The count(*) of a table in both Test and Production return the same value. However, a user of the table was doing some validation/testing and noticed that the sum of a column/field is different between the 2 environments. Being the better SQL user between the 2 of us, I'm trying to figure out how to find the discrepancies.
What's a good way to do so? This isn't that big of a table (~1 mill) but I'd like to keep the query/statement rather small
This is in Teradata
Upvotes: 0
Views: 2297
Reputation: 3361
Alright, here is a framework for you to build off of then. Since you are looking at sums and the like, you'll need to assemble most of the WHERE clause for this, since I don't have enough information to know what you are summing. So, I'll write this to find discrepencies in the rows themselves...
SELECT t1.id
FROM Production.[schema].table1 t1
INNER JOIN Test.[schema].table1 t2 ON t1.id = t2.id
WHERE t1.column <> t2.column
....
Just push the columns you want to compare into the WHERE clause...this will sync up the two tables from TEST and PROD and let you look for differences between columns. It will return a list of row ids where there is a mismatch.
Upvotes: 1