2014-06-09 54 views
1

我有一個場景,我想要從具有多個位置地址標記爲其他鏈接實體中的當前地址的實體中獲取人數。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> 
+1

請完善你的問題,指定更多的細節和實體 –

+0

@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

回答

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> 
+0

感謝您的回答 – Neodine

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> 
相關問題