I have three common table expressions that build the data for the results of the report. The data is summed and the client wants to see the details. In order to show the details I have to remove the PatientID parameter. That is where the problem comes in.
INNER JOIN [svcCount_cte] sc ON sc.svcCount = p.PatientID
INNER JOIN [staffCount_cte] ac ON ac.staffCount = p.PatientID
apparently needs the PatientID to link the data to do the calculation. My question is to look the the two sets of code and advise if there is a way to display the details of the data and not the summed by group as in the original.