Aggregation Query Builder doesn't count

Hi, We have reviewed in detail and we found that the problem is presented wi=
th aggregation query that use the attribute of patient that we have created.=
The postgres console print the next error.
ERROR: syntax error at or near ")" at character 617
STATEMENT: SELECT '0' as dataelementid, '0' as categoryoptioncomboid,
anisationunitid as sourceid, '0' as periodid,'DHIS-SYSTEM' as comment, '2013=
08' as periodIsoDate,'dataelementname' as dataelementname, 'optioncomboid' a=
s categoryoptioncomboname, as organisationunitname, count (psi.progr=
aminstanceid ) as value FROM programstageinstance as psi INNER JOIN organisa=
tionunit ou on ou.organisationunitid=3Dpsi.organisationunitid WHERE EXISTS (=
SELECT * FROM patientattributevalue _pav WHERE _pav.patientid =3D pi.patien=
tid and _pav.patientattributeid=3D280 AND p.organisationunitid in (0) AND _p=
av.value )=3D'Especial' ) GROUP BY ou.organisationunitid,

the error is generated when we edit the aggregation query, but it is don't g=
enerated with aggregation query that use the attibutes of patient that it is=
by default. (Sex).


ING. Helder Yesid Castrillon.
Secretar=C3=ADa departamental de salud