Click here to Skip to main content
14,640,678 members
Rate this:
Please Sign up or sign in to vote.
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

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"

1 solution

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

Solution 1

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



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
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100