select eo.NameOfInstitution,s.LastSurname,s.FirstName, dgp.CodeValue as GradingPeriodDescriptor, g.GradingPeriodBeginDate, gt.Description as GradeType , c.CourseTitle, g.ClassPeriodName, g.ClassroomIdentificationCode, dt.CodeValue as Term, g.BeginDate, g.LetterGradeEarned, g.NumericGradeEarned, g.DiagnosticStatement , pbt.Description as PerformanceBaseConversionType, st.LastSurname as TeacherLast, st.FirstName as TeacherFirst , das.CodeValue as SubjectCode,das.Description as Subject from edfi.Grade g left join edfi.Student s on s.StudentUSI=g.StudentUSI left join edfi.Descriptor dgp on dgp.DescriptorId=g.GradingPeriodDescriptorId left join edfi.GradeType gt on gt.GradeTypeId=g.GradeTypeId left join edfi.EducationOrganization eo on eo.EducationOrganizationId=g.SchoolId left join edfi.Section sec on sec.SchoolId=g.SchoolId and sec.SchoolYear=g.SchoolYear and sec.ClassPeriodName=g.ClassPeriodName and sec.ClassroomIdentificationCode=g.ClassroomIdentificationCode and sec.LocalCourseCode=g.LocalCourseCode and sec.UniqueSectionCode=g.UniqueSectionCode and sec.SequenceOfCourse=g.SequenceOfCourse and sec.TermDescriptorId=g.TermDescriptorId left join edfi.Descriptor dt on dt.DescriptorId=g.TermDescriptorId left join edfi.CourseOffering co on co.LocalCourseCode=g.LocalCourseCode and co.SchoolId=g.SchoolId and co.SchoolYear=g.SchoolYear left join edfi.Course c on c.CourseCode=co.CourseCode and c.EducationOrganizationId=co.EducationOrganizationId left join edfi.PerformanceBaseConversionType pbt on pbt.PerformanceBaseConversionTypeId=g.PerformanceBaseConversionTypeId left join edfi.StaffSectionAssociation ssa on ssa.SchoolId=g.SchoolId and ssa.SchoolYear=g.SchoolYear and ssa.ClassPeriodName=g.ClassPeriodName and ssa.ClassroomIdentificationCode=g.ClassroomIdentificationCode and ssa.LocalCourseCode=g.LocalCourseCode and ssa.UniqueSectionCode=g.UniqueSectionCode and ssa.SequenceOfCourse=g.SequenceOfCourse and ssa.TermDescriptorId=g.TermDescriptorId left join edfi.Staff st on st.StaffUSI=ssa.StaffUSI left join edfi.Descriptor das on das.DescriptorId=c.AcademicSubjectDescriptorId order by eo.NameOfInstitution,s.LastSurname,s.FirstName,g.TermDescriptorId,g.ClassPeriodName,gt.GradeTypeId