Rog D
asked on
SQL Sum of items in two tables not equal.
Table A
Item QOH
123 50
123 45
456 7
456 10
789 30
789 40
Table B
Item QOH
123 50
123 45
456 4
789 28
789 40
Result Set
Item QOH QOH
456 17 4
789 70 68
My goal is to find the items where the Sums are NOT equal.
Thanks.
Item QOH
123 50
123 45
456 7
456 10
789 30
789 40
Table B
Item QOH
123 50
123 45
456 4
789 28
789 40
Result Set
Item QOH QOH
456 17 4
789 70 68
My goal is to find the items where the Sums are NOT equal.
Thanks.
ASKER
This does not work as the sums are not calculated properly.
I believe it will require some sort of sub selects?
I believe it will require some sort of sub selects?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Did you try an UNION?
SELECT item, SUM(QOH)
FROM tableA
GROUP BY item
UNION
SELECT item, SUM(QOH)
FROM TableB
GROUP BY item
ASKER
Great this solution worked with correct results.
Thanks.
Thanks.
Open in new window