I have two data frames, which i want to combine usinga left join or similar.
PV number wise subtotal of the amount column of the dataframe (Pmt) has to be match with the second table (BankWithdrawal).
If such sub total matches, then join such row of with the 'BankWithdrawal' table.
Pmt Table
PVNo. Description Date ChqNo Amount
285922 ATL/16/154,151 PAYMENT FOR BRAN 01-04-16 250512 10404.00
285922 ATL/16/154,151 PAYMENT FOR BRAN 01-04-16 250512 16418.67
285904 PAYMENT FOR BRANCH RENT 01-05-16 900000.00
285912 SE14110206 OD WAVE OFF 10-05-16 250523 47250.00
285944 100P1605 - se vq fd chq 2016-4-4 01-07-16 400000.00
285942 FD WD PR 4970 10-07-16 533957 12154.25
285893 MAT WD PR 4963 15-07-16 176954.25
285893 MAT WD PR 4963 15-07-16 23045.75
Bank Withdrawal Table
B.Date |B.Description |B.ChqNo |B.Amount |
01-04-16 |Chq |250512 |26822.67 |
01-05-16 |Direct | |900000.00 |
20-05-16 |Chq |250523 |47250.00 |
30-06-16 |Other Chgs | |5000.00 |
20-07-16 |Direct | |200000.00 |
SQL code i tried
SELECT *
INTO [expectedTable]
FROM [pmt] p
inner join [Withdrawal] b
WHERE (SELECT sum(p.Amount) as 'PmtAmount'
FROM [pmt] p
GROUP BY p.PVNo) = b.[Withdrawals];
Error-
Incorrect syntax near the keword 'WHERE'
Can someone help me to get the correct code?
Thank you