I suggest you ...

XQuery 3.0: Count demo should sort prices numerically

Your "Count Clause" demo is misleading as it sorts prices based on its string representation. The following cast should by used in order to sort prices numerically:

for $p at $i in doc("products.xml")/products/product
order by xs:int($p/price) descending
count $rank
where $rank <= 3
return
<product rank="{$rank}">
{$p/name, $p/price}
</product>

1 vote
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Mike CoboMike Cobo shared this idea  ·   ·  Admin →

    0 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base