I am trying to get the count of distinct organisations/accounts with the below fetchxml.
The below query has two employments with the same organisation so I am expecting count to be 1. However it is returning 2 . Any solutions? Thanks.
<fetch aggregate="true" returntotalrecordcount="true">
 <entity name="sb_sb_employment_sb_application"> // Many to many relationship table
 <filter type="and">
 <condition attribute="sb_applicationid" operator="eq" value="GUID" />
 </filter>
 <link-entity name="sb_employment" from="sb_employmentid" to="sb_employmentid" link-type="inner" alias="employment">
<filter>
 <condition attribute="sb_dateto" operator="null" />
 <condition attribute="sb_organisationid" operator="not-null" />
 </filter>
 <link-entity name="account" from="accountid" to="sb_organisationid" link-type="inner">
 <attribute name="accountid" alias="AccountKey" groupby="true" />
 <attribute name="accountname" alias="billingname" aggregate="count" />
 </link-entity>
 </link-entity>
 </entity>
</fetch>
  
                            
                         
                        
                        
                            
                            *This post is locked for comments
                            
                            
                            
                            
                            
                            
                                I have the same question (0)