12,450,821 members (45,479 online)
Rate this:
See more:
Hi all

How to join Two Talble(Table1 is Fees_Transaction AND Table 2 is FeesMaster) With Condition

Here I use Code But It's Not Work Proper

```Dim strSQL5 As String = "SELECT Fees_Transaction.Regno, Fees_Transaction.ST_Name, SUM(Fees_Transaction.Amount_Paid) as FTAmountPaid,SUM(FeesMaster.FeeAmount) As TotalFeeAmount FROM  Fees_Transaction INNER JOIN FeesMaster  ON Fees_Transaction.Regno=FeesMaster.Regno and  Fees_Transaction.FeeType=FeesMaster.FeeType WHERE Fees_Transaction.class='" & cboClass.Text & "'  GROUP BY Fees_Transaction.Regno, Fees_Transaction.ST_Name"
```
Above Code ERROR is..

FeesMAster SUM Calculate Problem..

Pleaes HElp This COde..
Posted 19-Jan-13 6:30am
Updated 19-Jan-13 7:21am
v2

Rate this:

Solution 1

You should have shared what was not working properly for you.

Try:
```SELECT
Fees_Transaction.Regno, Fees_Transaction.ST_Name, SUM(Fees_Transaction.Amount_Paid) as FTAmountPaid,SUM(FeesMaster.FeeAmount) As TotalFeeAmount
FROM
Fees_Transaction
INNER JOIN
FeesMaster ON Fees_Transaction.Regno=FeesMaster.Regno
WHERE
Fees_Transaction.class='" & cboClass.Text & "'  AND Fees_Transaction.FeeType=FeesMaster.FeeType
GROUP BY
Fees_Transaction.Regno, Fees_Transaction.ST_Name```

Refer: MSDN: Using Inner Joins[^]
Navas Khanj 19-Jan-13 15:35pm

My FeesMaster.FeeAmount Calculate Two Time.. For Example My FeeAmount Data(750 + 650)=1400 but that one not Show Correct Value on DGV It Show 2800.. But Amount_Paid is Show Correct Value on DGV.
Sandeep Mewara 19-Jan-13 15:43pm

If you are sure that there is no duplicate record, try to put and see DISTINCT in the query in start and see:
SELECT
DISTINCT Fees_Transaction.Regno,...
Navas Khanj 19-Jan-13 16:07pm

I try to DIdtinct also but value calculate two time

Top Experts
Last 24hrsThis month
 Richard MacCutchan 110 ppolymorphe 105 OriginalGriff 65 Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ) 50 Karthik Bangalore 35
 OriginalGriff 6,053 Karthik Bangalore 3,500 ppolymorphe 3,491 Maciej Los 3,005 Richard Deeming 2,805