Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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
Edited 19-Jan-13 7:21am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

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[^]
  Permalink  
Comments
Navas Khanj at 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 at 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 at 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)

  Print Answers RSS
0 OriginalGriff 6,696
1 Sergey Alexandrovich Kryukov 6,675
2 CPallini 5,315
3 George Jonsson 3,584
4 Gihan Liyanage 2,650


Advertise | Privacy | Mobile
Web01 | 2.8.140921.1 | Last Updated 19 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100