Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All Please Help Me...
I have 3 Table View to DataGridView


This Table Data Want Display

Table1 (StudentDetails)			
Regno	Name	Class	Section
A100	Raja	I	A
A200	Ravi	I	A


This Table Filed Want Display To DataGridView Column

Table2(Fees Structure)
Class	FeeType	Total Amount	
I	Jan	1500	
I	Feb	2500	
I	Mar	1500	
I	Apr	3000	
I	Other	500



This Talbe Data Show to DGV
Table3 ( FeesTrans)
Regno 	Sname	Class	FeeType	Amount
A100	Raja	I	Jan	1000
A100	Raja	I	Jan	500
A100	Raja	I	Feb	2500
A100	Raja	I	Other	500
A200	Ravi	I	Jan	1500
A200	Ravi	I	Other	500


I want DataGridView Like This


Regno	Sname	Class	Section	Jan	Feb	Mar	Apr	Other	Total
A100	Raja	I	A	1500	500	0	0	500	2500
A200	Ravi	I	A	1500	0	0	0	500	200
Posted
Updated 18-Jan-13 0:16am
v4
Comments
Richard C Bishop 17-Jan-13 15:36pm    
This is not a question. Use the "Improve Question" widget to elaborate on what you are tring to achieve and provide the code you have attempted in order to accomplish that goal.

1 solution

try this. just modify the query and join the needed tables.
SQL
SELECT Regno, Sname, Class, Section,
SUM(CASE WHEN FeeType = 'Jan' THEN Amount ELSE 0 END) AS Jan,
SUM(CASE WHEN FeeType = 'Feb' THEN Amount ELSE 0 END) AS Feb,
SUM(CASE WHEN FeeType = 'Mar' THEN Amount ELSE 0 END) AS Mar,
SUM(CASE WHEN FeeType = 'Apr' THEN Amount ELSE 0 END) AS Apr,
SUM(CASE WHEN FeeType = 'Other' THEN Amount ELSE 0 END) AS Other,
SUM(FeeType) AS 'Total'
FROM <TableName>
GROUP BY Regno
 
Share this answer
 
Comments
Navas Khanj 18-Jan-13 6:06am    
Hi Tanks for Yor Replay.. But Wht i want.. Table 1 and Table 3 data Show to DataGirdView.. and Table 2 Data Show to DataGridView Column Header Text..

Please Tell Me

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