Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

FetchXML query with multiple Counts

$
0
0

I am trying to create  FetchXML query that will give me the Total Number of Open Leads and also the Total Number of Open Leads that do not have Open Activities against them.

I have the two queries:

Open Leads no Act:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" aggregate="true" >
  <entity name="lead" >
    <link-entity name="task" from="regardingobjectid" to="leadid" link-type="outer" alias="task" >
      <attribute name="regardingobjectid" aggregate="count" alias="TotalOpenLeadsNoActivities" />
    </link-entity>
    <filter type="and" >
      <condition entityname="task" attribute="regardingobjectid" operator="null" />
      <condition entityname="lead" attribute="statecode" operator="eq" value="0" />
    </filter>
  </entity>
</fetch>

AllOpenLeads:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" aggregate="true" >
  <entity name="lead" >
    <attribute name="leadid" aggregate="count" alias="TotalOpenLeads" />
    <filter type="and" >
      <condition entityname="lead" attribute="statecode" operator="eq" value="0" />
    </filter>
  </entity>
</fetch>

Is there a way to merge them so that I simply get two "COUNT" numbers returned by one query?

Thanks.


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images