Using an older Crystal Reports version and trying to insert a SQL expression which works in SQL Server Mgmt Studio but getting a syntax error in Crystal. Below is my SQL -
SELECT Sum(Cath_ACC.PCIProcedure)
FROM Demographics INNER JOIN Event_Cath ON Demographics.SS_Patient_ID = Event_Cath.SS_Patient_ID INNER JOIN Cath_Procedures ON Event_Cath.SS_Event_Cath_ID = Cath_Procedures.SS_Event_Cath_ID INNER JOIN Cath_ACC ON Event_Cath.SS_Event_Cath_ID = Cath_ACC.SS_Event_Cath_ID INNER JOIN SS_Selection_Set_Elements_BLGH ON Cath_Procedures.Procedure_Name = SS_Selection_Set_Elements_BLGH.Element_Text
WHERE SS_Selection_Set_Elements_BLGH.ACC_Field = 'Y'
AND (Event_Cath.Order_Number NOT LIKE 'IR%' or Event_Cath.Order_number is null)
AND (Cath_ACC.PCIProcedure = 1 or Cath_ACC.ProcedureDiagnostic = 1)
AND Event_Cath.Date_of_Cath > '20100101'
Group By Demographics.Patient_ID, Demographics.Last_Name, Demographics.First_Name,
Event_Cath.Order_Number, Event_Cath.Date_of_Cath
ORDER BY Demographics.Patient_ID, Demographics.Last_Name, Demographics.First_Name,
Event_Cath.Order_Number, Event_Cath.Date_of_Cath
Any help would be greatly appreciated. What I'm trying to do first group the records by PatientID, LastName, FirstName & Date. In the Details sections, I have all the procedures that were done. Each procedure would have both PCIProcedure & ProcedureDiagnostic. Then get the sum of PCIProcedure per group. Then I will evaluate the sum. It gets tricky because say you have 3 procedures and all 3 have the PCIProcedure having a value of 1. So when I get the sum, it is going to be three. The catch is I have to consider all three procedures as ONLY 1 count. That is why a simple sum formula will not work for me. I thought that by using a SQL expression, I will be able to add more logic for getting the true count. Thanks
Edited by josh2009 - 17 Feb 2010 at 9:53am