How to do calculation between 2 tables
I need to minus the dollar amount in Table A from Table B when they meet the criteria. Can T-SQL do this function?
For Example, when Year, MonthID, AcNo and Pid in Table A are the same as those in Table B, the Amt in Table A needs to minus the Amt in Table B.
Table A
Year MonthID AcNo Pid Amt
2002 1 1001 1 2000
2002 1 1001 2 2500
2002 1 1001 3 3000
Table B
Year MonthID AcNo Pid Amt
2002 1 1001 1 200
2002 1 1001 2 500
2002 1 1001 3 30
|