I am using this query to calculate percent change of Enrollment total from current semester to the last. What changes do I need to make to this query to avoid nulls ? I have tried using a sub query which is painfully slow.
SELECT E2.Term AS Prev_Term,
E2.[Enrollment Total] AS Prev_Enrl_Tot,
E1.Term,
E1.Location,
E1.milestone_description,
E1.polling_date,
Round(((E1.[Enrollment Total] - [Prev_Enrl_Tot])
/ [Prev_Enrl_Tot]) * 100,2) AS Percent_Change
FROM EnrollmentsByLocation E1
LEFT OUTER JOIN EnrollmentsByLocation E2
ON E1.Location = E2.Location
AND E1.milestone_description = E2.milestone_description
AND E1.Term - E2.Term = 1;