I have a Microsoft SQL view that uses 2 other views in it.



Can you try to combine all three into one.



Here is the main View:



SELECT

S.StudentUID,

S.StudentID,

S.LastName,

S.FirstName,

S.MiddleName,

S.Email1,

S.Email2,

F.TextTerm AS pTerm,

S.TextTerm AS cTerm,

S.EnrollmentStatus,

S.Campus,

Round( F.AttTermHrs, 0 ) AS prevTermAttHr,

Round( F.ErnTermHrs, 0 ) AS prevTermErnHr,

Round( F.CumAttemptedHours, 0 ) AS prevAttHr,

Round( F.CumEarnedHours, 0 ) AS prevErnHr,

F.AcademicStatus AS prevAcadStatus,

F.InstitutionalSAP AS prevAcaSAP,

F.GovernmentalSAP AS prevGovSAP,

S.AcademicStatus AS CurAcadStatus,

S.AcademicStatusID AS CurStatID,

S.InstitutionalSAP AS CurAcaSAP,

S.InstitutionalSAPID AS CurAcaID,

S.GovernmentalSAP AS CurGovSAP,

S.GovernmentalSAPID AS CurGovID,




Term = 'Term>',

Round( S.AttTermHrs, 0 ) AS curTermAttHr,

Round( S.ErnTermHrs, 0 ) AS curTermErnHr,

Round( F.TermGPA, 2 ) AS prevTermGPA,

Round( ( F.ErnTermHrs / F.AttTermHrs ), 4 ) AS prevTermProgress,

Round( S.TermGPA, 2 ) AS curTermGPA,

Round( ( S.ErnTermHrs / S.AttTermHrs ), 4 ) AS curTermProgress,




Cumulative = 'Cumulative>',

Round( S.CumAttemptedHours, 0 ) AS cAttHr,

Round( S.CumEarnedHours, 0 ) AS cErnHr,

Round( F.CumGPA, 2 ) AS prevGPA,

Round( ( F.CumEarnedHours / F.CumAttemptedHours ), 4 ) AS prevProgress,

Round( S.CumGPA, 2 ) AS cGPA,

Round( ( S.CumEarnedHours / S.CumAttemptedHours ), 4 ) AS cProgress,

SS.TextTerm as NextTerm,

SS.AcademicStatus AS nextSetAcaStatus,

SS.InstitutionalSAP AS nextSetAcaSAP,

SS.GovernmentalSAP AS nextSetGovSAP,

SS.AcademicStatusID AS nextSetAcaStatusID,

SS.InstitutionalSAPID AS nextSetAcaID,

SS.GovernmentalSAPID AS nextGovID


FROM

--update 1stterm SAP and 2nd Term Sap Views First - 2ndterm is the current term, 1st term is the prior term

CAMS_Merge_View_ForSAP_2ndTerm AS S

LEFT JOIN CAMS_Merge_View_ForSAP_1stTerm AS F ON F.StudentUID = S.StudentUID

LEFT Outer JOIN dbo.CAMS_StudentStatus_View AS SS ON SS.StudentUID = S.StudentUID and SS.TextTerm = 'FA-25'

--Bump this text term forward to the upcoming





Here is the view for the 1stTerm:

SELECT

dbo.Student.StudentUID,

dbo.Student.StudentID,

dbo.Student.LastName,

dbo.Student.FirstName,

dbo.Student.MiddleInitial AS MiddleName,

TRM.TextTerm,

TRM.TermCalendarID,

SS.EnrollmentStatus,

SS.Campus,

SS.AcademicStatus,

SS.InstitutionalSAP,

SS.InstitutionalSAPID,

SS.GovernmentalSAP,

SS.GovernmentalSAPID,

tGPA.Credits AS AttTermHrs,

tGPA.Earned AS ErnTermHrs,

tGPA.TermGPA,



 ISNULL

                          ((SELECT     TOP (1) CumAttemptedHours

                              FROM         dbo.CAMS_StudentCumulativeGPA_View_GPAGroupFix AS A

                              WHERE     (dbo.Student.StudentUID = StudentUID) AND (SS.TermCalendarID = TermCalendarID)), null) AS CumAttemptedHours, ISNULL

                          ((SELECT     TOP (1) CumEarnedHours

                              FROM         dbo.CAMS_StudentCumulativeGPA_View_GPAGroupFix AS A

                              WHERE     (dbo.Student.StudentUID = StudentUID) AND (SS.TermCalendarID = TermCalendarID)), null) AS CumEarnedHours, ISNULL

                          ((SELECT     TOP (1) CumGPA

                              FROM         dbo.CAMS_StudentCumulativeGPA_View_GPAGroupFix AS A

                              WHERE     (dbo.Student.StudentUID = StudentUID) AND (SS.TermCalendarID = TermCalendarID)), null) AS CumGPA



FROM

dbo.Student

LEFT OUTER JOIN dbo.CAMS_StudentStatus_View AS SS ON dbo.Student.StudentUID = SS.StudentUID

LEFT OUTER JOIN dbo.TermCalendar AS TRM ON SS.TermCalendarID = TRM.TermCalendarID

LEFT OUTER JOIN dbo.CAMS_StudentTermGPA_View_Fix AS tGPA ON dbo.Student.StudentUID = tGPA.StudentUID

AND SS.TermCalendarID = tGPA.TermCalendarID





WHERE    NOT (ss.campus = 'SATheologySeminary') and (StudentLoad is Not Null) and (StudentLoad <> '')

 and (TRM.TextTerm = 'FA-24') and ((SELECT     TOP (1) CumAttemptedHours

                              FROM         dbo.CAMS_StudentCumulativeGPA_View_GPAGroupFix AS A

                              WHERE     (dbo.Student.StudentUID = StudentUID) AND (SS.TermCalendarID = TermCalendarID))) is not null



Here is the View for the 2ndTerm



SELECT

dbo.Student.StudentUID,

dbo.Student.StudentID,

dbo.Student.LastName,

dbo.Student.FirstName,

dbo.Student.MiddleInitial AS MiddleName,

TRM.TextTerm,

TRM.TermCalendarID,

SS.EnrollmentStatus,

SS.Campus,

SS.AcademicStatus,

SS.AcademicStatusID,

SS.InstitutionalSAP,

SS.InstitutionalSAPID,

SS.GovernmentalSAP,

SS.GovernmentalSAPID,

dbo.Address.Email1,

dbo.Address.Email2,

tGPA.Credits AS AttTermHrs,

tGPA.Earned AS ErnTermHrs,

tGPA.TermGPA,


ISNULL

                          ((SELECT     TOP (1) CumAttemptedHours

                              FROM         dbo.CAMS_StudentCumulativeGPA_View_GPAGroupFix AS A

                              WHERE     (dbo.Student.StudentUID = StudentUID) AND (SS.TermCalendarID = TermCalendarID)), null) AS CumAttemptedHours, 


ISNULL

                          ((SELECT     TOP (1) CumEarnedHours

                              FROM         dbo.CAMS_StudentCumulativeGPA_View_GPAGroupFix AS A

                              WHERE     (dbo.Student.StudentUID = StudentUID) AND (SS.TermCalendarID = TermCalendarID)), null) AS CumEarnedHours, 


ISNULL

                          ((SELECT     TOP (1) CumGPA

                              FROM         dbo.CAMS_StudentCumulativeGPA_View_GPAGroupFix AS A

                              WHERE     (dbo.Student.StudentUID = StudentUID) AND (SS.TermCalendarID = TermCalendarID)), null) AS CumGPA



FROM

dbo.Student

LEFT OUTER JOIN dbo.Student_Address AS SA ON dbo.Student.StudentUID = SA.StudentID

LEFT OUTER JOIN dbo.Address ON SA.AddressID = dbo.Address.AddressID

LEFT OUTER JOIN dbo.Glossary AS g1 ON dbo.Student.TypeID = g1.UniqueId

LEFT OUTER JOIN dbo.Glossary AS g11 ON dbo.Address.AddressTypeID = g11.UniqueId

LEFT OUTER JOIN dbo.CAMS_StudentStatus_View AS SS ON dbo.Student.StudentUID = SS.StudentUID

LEFT OUTER JOIN dbo.TermCalendar AS TRM ON SS.TermCalendarID = TRM.TermCalendarID

LEFT OUTER JOIN dbo.CAMS_StudentTermGPA_View_Fix AS tGPA ON dbo.Student.StudentUID = tGPA.StudentUID

AND SS.TermCalendarID = tGPA.TermCalendarID





WHERE    (dbo.Address.ActiveFlag = 'Yes') AND (g11.DisplayText = 'Home') and NOT (ss.campus = 'SATheologySeminary') and (StudentLoad is Not Null) and (StudentLoad not in ('','Audit')) 

 and (TRM.TextTerm = 'SP-25') and ((SELECT     TOP (1) CumAttemptedHours

                              FROM         dbo.CAMS_StudentCumulativeGPA_View_GPAGroupFix AS A

                              WHERE     (dbo.Student.StudentUID = StudentUID) AND (SS.TermCalendarID = TermCalendarID))) is not null