What is the correct sql script for this select Statement?

eleveViagma

New Member
This is my script\[code\]SELECT iBranch_num, CASE WHEN iPatient_typ=1 THEN COUNT(iPatient_num) ELSE 0 END AS [New Patient], CASE WHEN iPatient_typ=2 THEN COUNT(iPatient_num) ELSE 0 END AS [Buying Patient], CASE WHEN iPatient_typ=3 THEN COUNT(iPatient_num) ELSE 0 END AS [Active Patient], CASE WHEN iPatient_typ=4 THEN COUNT(iPatient_num) ELSE 0 END AS [Inactive Patient]FROM tblsotransactionWHERE iStatus_typ=1 AND iApply_dt BETWEEN 20130401 AND 20130408 AND iBranch_num=14GROUP BY iBranch_num, iPatient_typ\[/code\]Current Result:\[code\]14, 25, 0, 0, 014, 0, 8, 0, 014, 0, 0, 97, 014, 0, 0, 0, 2\[/code\]I want the result to be like this\[code\]14, 25, 8, 9, 2\[/code\]
 
Back
Top