I am trying to use the following code:
m_Set.ClearQueryInfo();
m_Set.SetParameterWhere("PatID = @PatIDParam AND EffectiveEnrollmentDate IN (Select MAX(EffectiveEnrollmentDate))");
m_Set.SetWhere("PatID = ? AND EffectiveEnrollmentDate IN (Select MAX(EffectiveEnrollmentDate))");
m_Set.SetNumParams(1);
m_Set.SetParam("@PatIDParam", 1, PatIDParam.ToString());
but I get the following error:
An aggregate may not appear in WHERE if it is not in the subquery contained in the HAVING clause or selection list, and the column is an aggregated external link, SELECT dbo. [PatRoster]. * FROM dbo. [PatRoster] WHERE PatID = @PatIDParam AND EffectiveEnrollmentDate IN (Select MAX (EffectiveEnrollmentDate))
source
share