Skip to main content

Notifications

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>
  • Omar Bouattour Profile Picture
    Omar Bouattour 45 on at
    RE: How can I SELECT rows with MAX(Column value), PARTITION by another column with FetchXml

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

  • Ram Prakash Profile Picture
    Ram Prakash 2,285 on at
    RE: How can I SELECT rows with MAX(Column value), PARTITION by another column with FetchXml

    Hello,

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

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans