Hi @FijazM33449 ,
Please refer below update one:
select BranchID,TerminalID,count(type) count, sum(amount) Amount
from (
select BranchID,TerminalID,type,amount
from Calculate
except
select a.BranchID,a.TerminalID,a.type,a.amount
from Calculate a
inner join Calculate b on a.Amount=b.Amount and a.BranchID=b.BranchID
where a.Type='Deposit' and b.Type='DepositReversal'
except
select b.BranchID,b.TerminalID,b.type,b.amount
from Calculate a
inner join Calculate b on a.Amount=b.Amount and a.BranchID=b.BranchID
where a.Type='Deposit' and b.Type='DepositReversal' ) c
group by BranchID,TerminalID
Output:
BranchID TerminalID count Amount
Branch01 T01 1 1000
Branch02 T02 2 2500
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.