14,971,029 members
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

VB
`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
Updated 19-Jan-13 7:21am
v2
Member 12931435 13-Apr-17 11:46am

How to Join more than 1 database table in sql express(visualstudio 2010 )?

Solution 1

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

Try:
SQL
```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