Fetchxml 如何在 groupby fetch 中获取多个属性(聚合)
Fetchxml How to fetch multiple attributes in a groupby fetch (aggregate)
我有一个 fetchxml,在我向 fetch 添加另一个属性之前它工作正常。
<attribute name="ey_b_closed_conversations" alias="isClosed" />
这是我添加到 fetch 中的行,现在不起作用。
以下代码是完整的fetchxml。
<fetch mapping="logical" version="1.0" aggregate="true" distinct="false">
<entity name="ey_case_branch_callcenter_inquiry">
<attribute name="ey_s_name" alias="count" aggregate="countcolumn" />
<attribute name="ey_p_action" alias="id" groupby="true" />
<attribute name="ey_b_closed_conversations" alias="isClosed" />
<filter>
<condition attribute="ey_case_sub_subjectid" operator="eq" value="{9E52CB8E-BEA6-E411-AFFF-0050568C0143}" />
<condition attribute="statecode" operator="eq" value="0" />
</filter>
</entity>
</fetch>
我可以在聚合的 fetchxml 中获取的属性数量是否有任何限制?
如何将我的附加(非聚合)属性添加到提取中?
Are there any limitations on the number of attributes I can fetch in an aggregated fetchxml?
没有
How can I add my additional (non-aggregated) attribute to the fetch?
你不能。
您可能收到此错误:An attribute can not be requested when an aggregate operation has been specified and its neither groupby nor aggregate.
这类似于 SQL 错误:Column 'xxxx' is invalid in the select list because it is not
contained in either an aggregate function or the GROUP BY clause.
出现此错误是因为您查询中的以下行中没有 groupby
或 aggregate
属性。
<attribute name="ey_b_closed_conversations" alias="isClosed" />
This is because when you group by you can only include an attribute that you are not grouping-by as an aggregate ( E.g sum/min/max/count)
我测试了以下内容并且有效:
<fetch mapping="logical" version="1.0" aggregate="true" distinct="false" >
<entity name="account" >
<attribute name="name" alias="count" aggregate="countcolumn" />
<attribute name="telephone2" alias="phone" groupby="true" />
<attribute name="telephone1" alias="mobile" aggregate="count" />
<attribute name="accountnumber" alias="number" groupby="true" />
<filter>
<condition attribute="statecode" operator="eq" value="0" />
</filter>
</entity>
</fetch>
SQL相当于:
SELECT count(name) AS count,
count(telephone1) AS mobile,
telephone2 AS phone,
accountnumber AS number
FROM account
WHERE statecode = 0
GROUP BY telephone2, accountnumber
所以要么这样做:
<attribute name="ey_b_closed_conversations" alias="isClosed" aggregate="count" />
或
<attribute name="ey_b_closed_conversations" alias="isClosed" groupby="true" />
我有一个 fetchxml,在我向 fetch 添加另一个属性之前它工作正常。
<attribute name="ey_b_closed_conversations" alias="isClosed" />
这是我添加到 fetch 中的行,现在不起作用。 以下代码是完整的fetchxml。
<fetch mapping="logical" version="1.0" aggregate="true" distinct="false">
<entity name="ey_case_branch_callcenter_inquiry">
<attribute name="ey_s_name" alias="count" aggregate="countcolumn" />
<attribute name="ey_p_action" alias="id" groupby="true" />
<attribute name="ey_b_closed_conversations" alias="isClosed" />
<filter>
<condition attribute="ey_case_sub_subjectid" operator="eq" value="{9E52CB8E-BEA6-E411-AFFF-0050568C0143}" />
<condition attribute="statecode" operator="eq" value="0" />
</filter>
</entity>
</fetch>
我可以在聚合的 fetchxml 中获取的属性数量是否有任何限制? 如何将我的附加(非聚合)属性添加到提取中?
Are there any limitations on the number of attributes I can fetch in an aggregated fetchxml?
没有
How can I add my additional (non-aggregated) attribute to the fetch?
你不能。
您可能收到此错误:An attribute can not be requested when an aggregate operation has been specified and its neither groupby nor aggregate.
这类似于 SQL 错误:Column 'xxxx' is invalid in the select list because it is not
contained in either an aggregate function or the GROUP BY clause.
出现此错误是因为您查询中的以下行中没有 groupby
或 aggregate
属性。
<attribute name="ey_b_closed_conversations" alias="isClosed" />
This is because when you group by you can only include an attribute that you are not grouping-by as an aggregate ( E.g sum/min/max/count)
我测试了以下内容并且有效:
<fetch mapping="logical" version="1.0" aggregate="true" distinct="false" >
<entity name="account" >
<attribute name="name" alias="count" aggregate="countcolumn" />
<attribute name="telephone2" alias="phone" groupby="true" />
<attribute name="telephone1" alias="mobile" aggregate="count" />
<attribute name="accountnumber" alias="number" groupby="true" />
<filter>
<condition attribute="statecode" operator="eq" value="0" />
</filter>
</entity>
</fetch>
SQL相当于:
SELECT count(name) AS count,
count(telephone1) AS mobile,
telephone2 AS phone,
accountnumber AS number
FROM account
WHERE statecode = 0
GROUP BY telephone2, accountnumber
所以要么这样做:
<attribute name="ey_b_closed_conversations" alias="isClosed" aggregate="count" />
或
<attribute name="ey_b_closed_conversations" alias="isClosed" groupby="true" />