我有一个场景,我希望从一个实体中获取人数,这些实体在其他链接实体中将多个位置地址标记为当前地址。
<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>
答案 0 :(得分:1)
答案是
<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>
答案 1 :(得分:0)
请尝试以下操作 - 此代码将返回客户端数量。
<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>