Good Morning All.
I have a table structure (I am using SQL SERVER 2000)
CourseID StudentName TermPaperID
101 Jon 1
101 Jon 2
101 Jon 3
101 David 1
101 David 2
102 David 5
102 David 6
102 George 5
I would like to list out CourseID,StudentName,Maximum registration per Course.
I tried the following Query
select
CourseId,
StudentName,
max(x.numberofregistration) as max_registration
from
(
select
CourseID,
StudentName,
count(CourseID) as numberofregistration
from
dbo.Students
group by CourseId,StudentName
)x
group by CourseId,StudentName
but it did no give the expected result.
The expected result is
I have a table structure
CourseID StudentName max_registration
101 Jon 3
102 David 2
How to achieve the expected result? Thanks in advance.
Here’s a really, really ugly way. I think I’d rather pony up the upgrade fee than write too many of these. Hopefully someone else will come up with something cleaner.