Click here to Skip to main content
15,889,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All



I am Using 2 Tables (1 Table is Fees_Transaction another one Table is FeesMaster). I Want to JOIN 2 Talbe and Matching the Class and Regno From that Amount Shoud be Calculate and Display in the DataGridView.

I Try to This Code but it's notWorking... Please Help me.. How to Join and Caluclate Particular regno+Class amount.


Fees_Transaction Table Data
Regno ST_Name Class Section Amount_Paid FeeType
A600 BBBB I A 500 Team-1
A900 PPPP I A 750 Team-1
A700 DSDSDSDSD I A 500 Team-1
A700 DSDSDSDSD I A 250 Team-1
A700 DSDSDSDSD I A 300 Jan
A700 DSDSDSDSD I A 350 Jan
A600 BBBB I A 150 Team-1
A900 PPPP I A 200 Jan



FeesMaster : Table Data
Reg no Class Section Sname FeeType FeeAmount
A600 I A BBBB Team-1 650
A700 I A DSDSDSDSD Team-1 750
A900 I A PPPP Team-1 750
A600 I A BBBB Jan 650
A700 I A DSDSDSDSD Jan 650
A900 I A PPPP Jan 650

I WANT LIKE THIS IN DATAGRIDVIEW
Reg no ST_Name Amount_Paid FeeAmount FeeType Class Section

A600 BBBB 650 1300 TOTAL I A
A700 DSDSDSDSD 1400 1400 TOTAL I A
A900 PPPP 950 1400 TOTAL I A



Dim strSQL5 As String = "SELECT Fees_Transaction.Regno, Fees_Transaction.ST_Name, SUM(Fees_Transaction.Amount_Paid) as FTAmountPaid, FeeAmount FROM Fees_Transaction INNER JOIN (SELECT Class, SUM(FeeAmount) FROM FeesMaster WHERE FeesMaster.Class='" & cboClass.Text & "') as FeeAmount WHERE Fees_Transaction.Class='" & cboClass.Text & "' GROUP BY Fees_Transaction.Regno,Fees_Transaction.ST_Name"
Posted

1 solution

I'm not sure if I got your question right, I guess the way you should do it as below

Tbl_1
a
b
c

Tbl_2
d
e
f

and if you want data that is common in column a and d (in your case class and regno) then you do the below
SELECT tbl_1.a,tbl_1.b,tbl_1.c
FROM tbl_1 INNER JOIN tbl_2 on tbl_1.a = tbl_2.d
GROUP BY tbl_1.a, tbl_1.b, tbl_1.c

modify the above to suit your requirement
 
Share this answer
 
v2
Comments
Navas Khanj 18-Jan-13 9:59am    
This Join Two Table Ok.. But How to Match and Where Condition..? and TotolSum..

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