Click here to Skip to main content
15,910,886 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 3 tables in my db: STUDENT, BOOK and GRADE. Book table has the result column, Each student take few book. In Grade table there is a column named average (average of results for book of student). Is it possible to show in Datagridview a cross table where each row refer to a student and each column refer to a book result and one column for average?
Posted

1 solution

You mean something like this?

SELECT TABLE1.COL, TABLE2.COL, TABLE3.COL
FROM TABLE1
JOIN TABLE2 ON TABLE1.ID = TABLE2.ID
JOIN TABLE3 ON TABLE1.ID = TABLE3.ID
 
Share this answer
 
Comments
siaswar 4-Mar-11 6:23am    
No. This is Join and I know it. Each row in student has many rows in book. I want a table that shows student_name in row_header and book_name in column header and result in cross.
==>student table:
st_name nvarchar(20);
st_family nvarchar(30);
class_id int;

==>book table:
book_name nvarchar(30),
st_id int,
result single,

I want to show somthing like this:
-------------------------------------------
student| math | english | Geo | ...
-------------------------------------------
John | 35 | 67.5 | 79 | ...
Mark | 89.25| 75 | 92 | ...
Sam | 68 | 74 | 69 | ...
----------------------------------------
So each row in my table comes from student table and each column comes from book table
[no name] 4-Mar-11 8:22am    
Yes, that explains it better. I believe what you want is a PIVOT, http://msdn.microsoft.com/en-us/library/ms177410.aspx

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