SQL Query - Calculate SUM Across two tables

BobBarker_99
BobBarker_99 used Ask the Experts™
on
This must be really simply, but I'm not seeing how to do it right now.

I want to do the following in 1 sql statement so I dont have to do 2 data access.

SELECT SUM(fldAmount) from tbl1 where fldID = @ContactID
-
SELECT SUM(fldRate * fldHours) from tbl2 WHERE fldID = @ContactID

(there is a subtraction between the 2 sums)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
select (
SELECT SUM(fldAmount) from tbl1 where fldID = @ContactID ) -
(SELECT SUM(fldRate * fldHours) from tbl2 WHERE fldID = @ContactID)

Author

Commented:
Doh, I had that all along, just missing a bracket gave me a cryptic error msg.  Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial