In the following two SELECT statements, I'd like to compare the outputs from these two to get the IDs of the amounts don't match.
The GROUP BY and SUMs in the first statement seem to be complicating things:
SELECT CreditAHID,
SUM(Debit) as CCDebit,
SUM(Credit) as CCCredit,
FROM FS_2015_June.dbo.CCs
GROUP BY CreditAHID
SELECT ID as CreditAHID,
JuneDebit as AHDebit,
JuneCredit as AHCredit,
FROM FS_2015_2016.dbo.AHs
Is there any way to combine them to something like this?
SELECT ID ... WHERE (CCDebit != AHDebit) OR (CCCredit != AHCredit)
Try this query below:
This query will return the combination of both results where a CreditAHID matches in both results and where the
CCDebitandCCCreditis not equal toAHDebitandAHCreditrespectively.