【问题标题】:XQuery order by ascending and descendingXQuery 按升序和降序排列
【发布时间】:2011-08-25 11:22:09
【问题描述】:

在 XQuery 中,如何按升序和降序排序?

我从教程中得到了以下内容:

for $x in doc("books.xml")/bookstore/book
where $x/price>30
order by $x/title
return $x/title

会不会

for $x in doc("books.xml")/bookstore/book
where $x/price>30
order by $x/title ascending
return $x/title

【问题讨论】:

    标签: xml xquery


    【解决方案1】:

    是的,您可以在order by.. 表达式的末尾使用ascending(默认)或descending

    这是 W3C XQuery 规范相关部分的链接:

    http://www.w3.org/TR/xquery/#doc-xquery-OrderSpec

    【讨论】:

    • so it would befor $x in doc("books.xml")/bookstore/book where $x/price>30 order by increasing $x/title return $x/title
    • 或者是 $x in doc("books.xml")/bookstore/book where $x/price>30 order by $x/title return $x/title 升序
    • 我写了“在表达式之后”,我的意思是这样的:... order by $x/title ascending ...(就像你在问题中写的那样,这是正确的语法)。
    【解决方案2】:

    查看我对this question的回复。代码演示了降序排序。

    对于升序排序,ascending关键字可以省略。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-08
      • 2012-11-08
      • 2023-03-07
      • 2016-10-18
      • 2017-11-16
      • 1970-01-01
      相关资源
      最近更新 更多