Click here to Skip to main content
11,412,159 members (61,386 online)
Rate this: bad
Please Sign up or sign in to vote.
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 18-Jan-13 12:22pm
PIEBALDconsult at 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 at 18-Jan-13 18:47pm
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
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

to do that use the Group BY Clause of sql

refer this link[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

from studentcoursestable

group by course_id

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 348
1 Sergey Alexandrovich Kryukov 225
2 Sascha Lefévre 175
3 ProgramFOX 130
4 Maciej Los 110
0 Sergey Alexandrovich Kryukov 8,980
1 OriginalGriff 7,263
2 Maciej Los 3,500
3 Abhinav S 3,248
4 Peter Leow 3,059

Advertise | Privacy | Mobile
Web01 | 2.8.150414.5 | Last Updated 19 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100