FetchXML:获取基于链接实体的字段的记录数
问题描述:
我有一个场景,我想要从具有多个位置地址标记为其他链接实体中的当前地址的实体中获取人数。FetchXML:获取基于链接实体的字段的记录数
<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>
答
请尝试以下内容 - 此代码将返回您的客户端数量。
<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>
+0
感谢您的回答 – Neodine
答
答案是
<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>
请完善你的问题,指定更多的细节和实体 –
@GuidoPreite这是SQL查询,我要转换为Fetchxml的真实姓名。 从ifx_client [代码]选择ifx_name,计数(ifx_isthiscurrent),ifx_locationaddress其中ifx_client.ifx_clientid = ifx_locationaddress.ifx_clientid和ifx_isthiscurrent = 1组由具有ifx_name计数(ifx_isthiscurrent)> 1 [代码] – Neodine