Hi All
I would like to store in a row of a 'Totals' table the sum calculated from 2 other tables.
I want to use a column for each table.
I tried the following:
INSERT INTO Totals ( Date, FirstTableSum, SecondTableSum ) SELECT '2010/01/31', SUM( t.Data1 ), SUM( v.Data2 ) FROM FirstTable as t, SecondTable as v WHERE t.Date = '2010/01/31' AND v.Date = '2010/01/31'
If I make a query to check the sums of the 2 distinct tables I have different values.
SELECT SUM(Data1) FROM FirstTable WHERE Date='2010/01/31' /*The result is different from FirstTableSum: Why?*/ SELECT SUM(Data2) FROM SecondTable WHERE Date='2010/01/31' /*The result is different from SecondTableSum Why?*/
What am I doing wrong?
Thanks