Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8883381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:47:56+00:00 2026-06-14T20:47:56+00:00

How do i return all the maximum values in xquery? I used max() but

  • 0

How do i return all the maximum values in xquery? I used max() but it only gives me one! Thanks.

<id>a</id>
<average>5</average>
<id>b</id>
<average>5</average>
<id>c</id>
<average>5</average>
<id>d</id>
<average>4</average>
<id>e</id>
<average>1</average>

and i want my results to be:

<id>a</id>
<id>b</id>
<id>c</id>

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:47:58+00:00Added an answer on June 14, 2026 at 8:47 pm

    Use:

    /*/id[following-sibling::*[1]/number() eq max(/*/average)]
    

    The above is both a correct XQuery and a correct XPath 2.0 solution.

    Verification with Saxon EE 9.3.04 XQuery:

    When the above XQUery is applied on the following XML document (the provided fragment, wrapped into a single top element to make it a well-formed XML document):

    <t>
        <id>a</id>
        <average>5</average>
        <id>b</id>
        <average>5</average>
        <id>c</id>
        <average>5</average>
        <id>d</id>
        <average>4</average>
        <id>e</id>
        <average>1</average>
    </t>
    

    the wanted, correct result is produced:

    <?xml version="1.0" encoding="UTF-8"?><id>a</id><id>b</id><id>c</id>
    

    When this XSLT 2.0 transformation is applied (using Saxon 9.1.05) on the same XML document (above):

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="/">
      <xsl:sequence select=
       "/*/id[following-sibling::*[1]/number() eq max(/*/average)]"/>
     </xsl:template>
    </xsl:stylesheet>
    

    again the same correct result is produced:

    <id>a</id>
    <id>b</id>
    <id>c</id>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I simply want to return all rows from a users table but selected fields,
I have to return all my JSON string. For example I have one json
I am trying to use Linq2Sql to return all rows that contain values from
To get all contacts I'm using ABAddressBookCopyArrayOfAllPeople method but, this method return all contacts
The scenario: Table1 CatId|Name|Description Table2 ItId|Title|Date|CatId (foreign key) I want to return all rows
Is there a way to return all the columns in a MySQL table in
Running a query which should return all open questions along with the last update
I have this following code which will return all the current semesters. How do
I am writing a query which needs to return all child entries (and their
How would I go about using regx to return all characters between two brackets.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.