I would debug this in two steps. First, remove the entire code for the column that has the subquery and run it.SELECT I."Lab Number" +' '+ I.LatentLetter +' '+I.ItemSource As [IMPRESSION], E1.EvidenceID as ARandomColumnFromEvidenceFROM LIMS_DATA_Production.dbo.EvidenceSubjects E1RIGHT JOIN LIMS_DATA_Production.dbo.Impressions I ON E1.EvidenceID = I.ID WHERE I.CaseID = 9307 and I.SDelete = 0GROUP BY I.CaseID, E1.EvidenceID, I."Lab Number", I.LatentLetter, I.ItemSourceORDER BY IMPRESSION
Do you get at least one row from the IMPRESSIONS table for which there are no EvidenceSubjects? If you are not getting any rows, it is because of the where clause. Look at the where clause to understand why.If that does not seem to be the problem, change the code as follows:SELECT I."Lab Number" +' '+ I.LatentLetter +' '+I.ItemSource As [IMPRESSION],ISNULL( (SELECT (CASE E2.Evaluation WHEN 1 THEN 'IND' WHEN 2 THEN 'EXC' WHEN 3 THEN 'INC' WHEN 4 THEN 'ICP' END) + ' to ' ,S.SubjectLastName +' , '+S.SubjectFirstName +': ' FROM LIMS_DATA_Production.dbo.EvidenceSubjects E2 INNER JOIN LIMS_DATA_Production.dbo.Subjects S ON E2.SubjectID = S.ID WHERE S.CaseID = I.CaseID AND S.SDelete = 0 AND E1.EvidenceID = E2.EvidenceID FOR XML PATH ('') ),'No Evidence') AS RESULTSFROM LIMS_DATA_Production.dbo.EvidenceSubjects E1RIGHT JOIN LIMS_DATA_Production.dbo.Impressions I ON E1.EvidenceID = I.ID WHERE I.CaseID = 9307 and I.SDelete = 0GROUP BY I.CaseID, E1.EvidenceID, I."Lab Number", I.LatentLetter, I.ItemSourceORDER BY IMPRESSION