Saturday, 16 April 2016

Count Distinct Columns - FetchXML Query

The following FetchXML counts all opportunities with distinct names
  1. <fetch distinct='false' mapping='logical' aggregate='true'>
  2. <entity name='opportunity'>
  3. <attribute name='name' alias='opportunity_distcount' aggregate='countcolumn' distinct='true'/>
  4. </entity>
  5. </fetch>
Explanation
To count distinct column values
  • Set aggregate to true in fetch clause.
  • Set aggregate to countcoumn in aggregate attribute
  • Set distinct to true
- See more at: http://msxrmtools.com/fetchxml/reference

No comments:

Post a Comment