I have a scenario where i want to get the count of people from an Entity who have multiple location address marked as current address in other linked entity.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" aggregate="true">
<entity name="client">
<attribute name="clientid"/>
<attribute name="name"/>
<attribute name="createdon"/>
<order attribute="name" descending="false"/>
<link-entity name="locationadd" from="clientid" to="clientid" alias="aa">
<attribute name="locationadd" aggregate="countcolumn" />
<filter type="and">
<condition attribute="isthiscurrentadd" operator="eq" value="1"/>
</filter>
</link-entity>
</entity>
</fetch>
The answer is
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true' aggregate='true'>
<entity name='client'>
<attribute name='clientid' alias='PersonName' groupby='true' />
<link-entity name='locationadd' from='clientid' to='clientid' alias='aa'>
<attribute name='isthiscurrentadd' alias='Count' aggregate='count'/>
<filter type='and'>
<condition attribute='isthiscurrentadd' operator='eq' value='1'/>
</filter>
</link-entity>
</entity>
</fetch>
Try following - this code will return you the number of clients.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" aggregate="true">
<entity name="client">
<attribute name="clientid" aggregate='count' alias='clientscount'/>
<link-entity name="locationadd" from="clientid" to="clientid" alias="aa">
<attribute name="locationadd" aggregate="countcolumn" />
<filter type="and">
<condition attribute="isthiscurrentadd" operator="eq" value="1"/>
</filter>
</link-entity>
</entity>
</fetch>