I have two queries that run fairly quickly, and would like the results of each to appear in a single grid, without using a temp table.
Here's how I'm doing the selection ...
... and here's how I'd like the output to look:
UNION and UNION ALL don't seem to produce the desired results.
My brain is stuck on how to do it using a temp table or table variable, and I'm pretty sure I'm overlooking something VERY obvious.
Thanks in advance!
Bryant Farley
EG&G Technical Services
Here's how I'm doing the selection ...
Code:
SELECT AcctNo, AcctName, SUM(TransAmt) AS Table1Total
FROM Table1
WHERE TransDate BETWEEN '4/1/08' AND '5/1/08'
GROUP BY AcctNo
SELECT AcctNo2, AcctName2, SUM(TransAmt2) AS Table2Total
FROM Table2
WHERE TransDate2 BETWEEN '4/1/08' AND '5/1/08'
GROUP BY AcctNo2
... and here's how I'd like the output to look:
Code:
123456 Fudd 224,117.69 224,117.50
234567 Duff 339,775.91 339,577.19
345678 Fbar 982,833.75 833,982.57
UNION and UNION ALL don't seem to produce the desired results.
My brain is stuck on how to do it using a temp table or table variable, and I'm pretty sure I'm overlooking something VERY obvious.
Thanks in advance!
Bryant Farley
EG&G Technical Services