Click here to Skip to main content
14,271,310 members
Rate this:
Please Sign up or sign in to vote.
See more:
I want to write a query to find out how many students got average GPA? I am getting right answer when i just find out average GPA, but i don't know how to count the number of students who got average GPA.
here is my query, but it is not giving the right answer
Select count (Sid), Avg (GPA)
from Student
group by Sid

What I have tried:

Select count (Sid), Avg (GPA)
from Student
group by Sid
Posted
Comments
Manas_Kumar 10-Feb-16 1:25am
   
Provide demo data with your need(what output do you need)?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Try:
SELECT COUNT(*) 
FROM Student a
JOIN (SELECT AVG(GPA) AS av FROM Student) b
ON a.GPA = b.av
   

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




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