I am designing a Union query between to tables in order to sum to like fields:
I was wondering if it would be more efficent if if I just sum'ed the Sum1 Fields in the Main Query like This:Code:SELECT OBJNUM, Sum(SUM1) AS HASH FROM ( SELECT Table1.OBJNum AS OBJNUM, Sum(Table1.EMPNUM) as Sum1 FROM Table1 GROUP BY Table1.OBJNum UNION SELECT Table2.OBJNum AS OBJNUM, Sum(Table2.VENNUM) as Sum1 FROM Table2 GROUP BY Table2.OBJNum ) GROUP BY OBJNUM;
Any thoughts?Code:SELECT OBJNUM, Sum(SUM1) AS HASH FROM ( SELECT Table1.OBJNum AS CASENUM, Table1.EMPNUM as Sum1 FROM Table1 GROUP BY Table1.OBJNum, Table1.EMPNUM UNION SELECT Table2.OBJNum AS OBJNUM, Table2.VENNUM as Sum1 FROM Table2 GROUP BY Table2.OBJNum, Table2.VENNUM ) GROUP BY OBJNUM;




Reply With Quote