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

I have a table of courses and another for students.
And I need to fill a grid view with the following information

1- course ID
2- course name
3- number of students in each course

Without repeating the course name, means each course in a single row.

Note: I am using a query builder.

than you
Posted
Comments
PIEBALDconsult 18-Jan-13 18:42pm    
More information is required. There ought to be a table to provide a many-to-many relationship between the students and courses.
Nasser Abu Farah 18-Jan-13 18:47pm    
OK
I have the three tables, what I am really concerned about is how to calculate the number of students in the StudentCourses table for each course using the query builder or a C# code.
thank you

to do that use the Group BY Clause of sql

refer this link
http://www.tizag.com/sqlTutorial/sqlgroupby.php[^]
 
Share this answer
 
select
course_id,
count(students_id)
from studentcoursestable

group by course_id

---format syntax and object names
---and next time do a little google search
 
Share this answer
 

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