Longish post.
I have two tables, each about 35,000 rows, derived from different data sources. I need to compare that the calculations based on each of the tables yield equal results. For example, as a quality check, I need to sum "Sales" for each table, and compare the results, which should be equal.
table_1
Region | Sales
=================
NE 1000
SW 1250
.
.
.
n
table_2
Region | Sales
=================
NE 1000
SW 1250
.
.
.
n
I've tried the following query:
SELECT SUM(t1.sales), SUM(t2.sales)
FROM table_1 t1, table_2 t2
However, I wind up with a wild number, equal to the actual sum of sales for one table, multiplied by the number of rows in the other table.
I have similar calculations and comparisons that I need to make between these two tables, and need to develop a consistent way to handle these kinds of SQL manipulations.
Thanks.
I have two tables, each about 35,000 rows, derived from different data sources. I need to compare that the calculations based on each of the tables yield equal results. For example, as a quality check, I need to sum "Sales" for each table, and compare the results, which should be equal.
table_1
Region | Sales
=================
NE 1000
SW 1250
.
.
.
n
table_2
Region | Sales
=================
NE 1000
SW 1250
.
.
.
n
I've tried the following query:
SELECT SUM(t1.sales), SUM(t2.sales)
FROM table_1 t1, table_2 t2
However, I wind up with a wild number, equal to the actual sum of sales for one table, multiplied by the number of rows in the other table.
I have similar calculations and comparisons that I need to make between these two tables, and need to develop a consistent way to handle these kinds of SQL manipulations.
Thanks.