web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

How can I SELECT rows with MAX(Column value), PARTITION by another column with FetchXml

(0) ShareShare
ReportReport
Posted on by 45

Hello I have a table that looks like this:

5280.Sans-titre.png

I want select the distinct rows of (numero column) with the max value of the (score column) so for example all the rows with (numero = 13) i want to just get the row with the max score

so my table becomes like this:

Numero Score

12          20

13          50

5            50

I tried this but it didnt work and i get this error (

{"error":{"code":"0x8004111e","message":"An attribute can not be requested when an aggregate operation has been specified and its neither groupby nor aggregate.  NodeXml : <attribute name=\"zs_name\" />"}})


<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" aggregate="true">
<entity name="zs_reponse">
<attribute name="zs_name" />
<attribute name="zs_score" alias='estimatedvalue_max' aggregate='max' />
<attribute name="zs_reponseid" />
<order attribute="zs_name" descending="false" />
<filter type="and">
<condition attribute="zs_question" operator="not-null" />
<condition attribute="zs_score" operator="not-null" />
<condition attribute="zs_parcours" operator="not-null" />
</filter>
<link-entity name="zs_question" from="zs_questionid" to="zs_question" visible="false" link-type="outer" alias="a_c876717f515c4c5aa50b931b9b0e6c51">
<attribute name="zs_coefficient" />
<attribute name="zs_groupe" />
<attribute name="zs_intitulefr" />
<attribute name="zs_numero" distinct="true" />
<attribute name="zs_parcours" />
</link-entity>
</entity>
</fetch>
  • Ram Prakash Duraisamy Profile Picture
    2,289 on at

    Hello,

    Is it a whole Number field? i can see it is a text field.

  • Omar Bouattour Profile Picture
    45 on at

    the zs_score is a whole number and i want to get the max value of it according to a distinct "zs_numero"

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 89 Most Valuable Professional

#2
11manish Profile Picture

11manish 67 Super User 2026 Season 2

#3
Travis South Profile Picture

Travis South 39

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans