Skip to main content

Notifications

Announcements

No record found.

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

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans