SELECT Payment_Id, Pay_Booking_Id, Convert(varchar(50),Payment_Date,103)AS Payment_Date,Narration,Amount,
CASE WHEN Transaction_Type = 'M' THEN 'Mile Stone' ELSE CASE WHEN Transaction_Type = 'R' THEN 'Reciept' ELSE CASE WHEN Transaction_Type = 'P' THEN 'Payment' ELSE CASE WHEN Transaction_Type = 'DT' THEN 'Direct Transfer' ELSE CASE WHEN Transaction_Type = 'C' THEN 'Journel Credit' ELSE 'Journel Debit' END END END END END as Transaction_Type ,
CASE WHEN Transaction_Type = 'M' THEN
ISNULL((SELECT SUM(Adj_Amount) FROM Adjustment WHERE Adj_What_Id = Payment_Id ), 0.000)
ELSE
ISNULL((SELECT SUM(Adj_Amount) FROM Adjustment WHERE Adj_Payment_Id = Payment_Id AND Adj_What_Id = Payment_Id),0.000)
END AS Adj_Amount_OtherTxn,
0.000 AS Adj_Amount_thisTxn
FROM Payment Pay WHERE Pay_Booking_Id = @Booking_Id
Given Below Image Where Payment _Id 496 Which Transaction type in PAyment it is amount Subtract in Payment _Id 240 Which Transaction type AGREEMENT
Like Agreement Amt = 521807.000
Payment Amt = 4000.000
Which minus Amount shoulde be 517807.000