Click here to Skip to main content
14,971,029 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Comments
Member 12931435 13-Apr-17 11:46am
   
How to Join more than 1 database table in sql express(visualstudio 2010 )?

1 solution

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[^]
   
Comments
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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900