StudentStatisticsData.sql 1.4 KB

1234567891011121314151617181920212223
  1. SELECT
  2. class.ClassNum AS classNo ,class.Name AS className, grade.GradeID AS year,
  3. Standards.Name AS StandardsName,college.Name AS collegeName,
  4. school.Code AS schoolCode,
  5. unicersity.Name AS unicersityName,
  6. COUNT(1) as StudentCount FROM dbo.CF_Student student
  7. INNER JOIN dbo.CF_InSchoolSetting InSchoolSetting ON InSchoolSetting.InSchoolStatusID = student.InSchoolStatusID --AND InSchoolSetting.IsSelected=1
  8. INNER JOIN dbo.CF_Classmajor class ON class.ClassmajorID = student.ClassmajorID
  9. INNER JOIN dbo.CF_Grademajor grade ON grade.GrademajorID = class.GrademajorID
  10. INNER JOIN dbo.CF_Facultymajor faculty ON faculty.FacultymajorID = grade.FacultymajorID
  11. INNER JOIN dbo.Sys_DictionaryItem Standards ON Standards.Value = faculty.StandardID AND Standards.DictionaryCode = 'CF_Standard'
  12. INNER JOIN dbo.CF_College college ON college.CollegeID = faculty.CollegeID
  13. INNER JOIN dbo.CF_Campus campus ON campus.CampusID = college.CampusID
  14. INNER JOIN dbo.CF_University unicersity ON unicersity.UniversityID = campus.UniversityID
  15. INNER JOIN dbo.CF_Schoolyear Schoolyear ON Schoolyear.SchoolyearID = grade.GraduateSchoolyearID
  16. INNER JOIN dbo.CF_Schoolyear school ON school.IsCurrent=1 AND school.Value<=Schoolyear.Value
  17. WHERE (@INSchoolStatus is null or InSchoolSetting.IsSelected=@INSchoolStatus)
  18. GROUP BY class.ClassNum,class.ClassmajorID,class.Name,
  19. grade.GrademajorID,grade.GradeID,
  20. college.Name,Standards.Name,
  21. Schoolyear.Code,school.Code,
  22. unicersity.Name
  23. ORDER BY class.ClassNum, class.Name