If a record can't be found I'd like the query to return a 0 ...at the moment my query returns are blank when a record isn't located. Thought using CASE would do the trick but no dice. Need some help with this ...thank you.
SELECT CASE when DATEDIFF(DAY,p.StartOfCare, cna.VisitDate) = '' THEN 0 ELSE DATEDIFF(DAY,StartOfCare,cna.VisitDate) end AS Result
FROM Comp_Nurse_Assess cna INNER JOIN Patient p ON p.ID = cna.Patient_ID_Num
LEFT OUTER JOIN QANursingForms qa
ON cna.Patient_ID_Num = qa.PatientID
WHERE qa.Form_Title = 'Comp. Nursing Assessment' AND qa.QAComplete <> 1 AND p.Clientid = 5001 AND p.MRNum = '3336'