Hi i have this query
SELECT TriageToDoctor, DoctorToBedRequest, BedRequestToDepart,DepartureDate FROM EmergencyDepartment WHERE DepartureDate >=DATEADD(day, -28, GETDATE()) and DepartureMethod ='Admitted' Group BY TriageToDoctor, DoctorToBedRequest, BedRequestToDepart,DepartureDate ) Select * ,CASE WHEN DepartureDate>=DATEADD(Day,-1,GETDATE())then 'RunDate' else '' END AS '<1Day' ,CASE WHEN DepartureDate >=DATEADD(Day,-7,GETDATE()) Then '-7 Days' Else '' END AS '<7Days' ,CASE WHEN DepartureDate >=DATEADD(DAy,-28,GETDATE()) THEN '-28 Days' ELSE '' END AS '<28Days' FROM Base GROUP BY TriageToDoctor, DoctorToBedRequest, BedRequestToDepart,DepartureDate ORDER BY DepartureDate ASCIt produces this output
However i need to produce this result by as an average
How can i get this, thanks
David