Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
geniussandy
Starting Member
1 Post |
Posted - 2010-09-01 : 12:10:18
|
| I have 3 tableslogin ( student_id,password)student_academics_info(student_id,CGPA,branch)where CGPA is Cumulative Grade Point Average at scale of 10student_personal_info(student_id,sex)i want to write a query to get average CGPA of males of each branch and average CGPA of females of each branch.--Sandeep Agarwal |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-01 : 12:12:50
|
| whats formula?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
rohitvishwakarma
Posting Yak Master
232 Posts |
Posted - 2010-09-02 : 08:35:54
|
| hi sandeep,Following is the query:SELECT A.branch,P.student_sex,SUM(A.CGPA) as TotalCGPA, COUNT(L.student_id) TotalStudents ,SUM(A.CGPA)/COUNT(L.student_id) AS AverageFROM login L INNER JOIN student_academics_info AON L.student_id = A.student_idINNER JOIN student_personal_info PON L.student_id =P.student_idWHERE branch IN (select distinct branch from student_academics_info )GROUP BY A.branch,P.student_sexIf there is any issue with the query or you need more details then feel free to revert back |
 |
|
|
|
|
|