David B.
David B.

Reputation: 1

Distincts rows in a FetchXml query

In this FetchXml Query, I want to get distinct row but I get many time the same cic_disponibilitesid value. It's because more than one row in cic_engagements are related to the cic_disponibilites row.

<fetch distinct="true">
  <entity name="cic_disponibilites">
    <attribute name="cic_date" />
    <attribute name="cic_disponibleam" />
    <attribute name="cic_disponiblepm" />
    <attribute name="cic_disponibilitesid" />
    <filter type="and">
      <condition attribute="cic_date" operator="ge" value="2024-01-01" />
      <condition attribute="cic_date" operator="le" value="2024-02-28" />
      <condition attribute="cic_nameofcustomer" operator="eq" value="Brad Copper" />
    </filter>
    <link-entity name="cic_engagements" from="cic_disponibilite" to="cic_disponibilitesid" link-type="outer" alias="Engagements">
      <attribute name="cic_name" />
    </link-entity>
  </entity>
</fetch>

I tried to add "Distinct" keyword but it does not fix it

Upvotes: 0

Views: 42

Answers (1)

Andrew Butenko
Andrew Butenko

Reputation: 5446

I believe it's related to your join and to be more specific selecting the "cic_name" field out of it. If values there are different - that's why you are getting as many lines as you have unique related records of cic_engagements. Can you please clarify what's the end results of what you are trying to achieve?

Upvotes: 0

Related Questions