xml XQuery 按升序和降序排列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6001357/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
XQuery order by ascending and descending
提问by Tuffy G
In XQuery, How do you order by ascending and descending?
在 XQuery 中,如何按升序和降序排序?
I have got the following from a tutorial:
我从教程中得到了以下内容:
for $x in doc("books.xml")/bookstore/book
where $x/price>30
order by $x/title
return $x/title
would it be
可不可能是
for $x in doc("books.xml")/bookstore/book
where $x/price>30
order by $x/title ascending
return $x/title
回答by Lucero
Yes, you can use ascending(default) or descendingat the end of the order by..expression.
是的,您可以使用ascending(default) 或descending在order by..表达式的末尾。
Here's the link to the relevant part of the W3C XQuery spec:
这是 W3C XQuery 规范相关部分的链接:
回答by Dimitre Novatchev
See my answer to this question. The code demonstrates ordering in descending order.
请参阅我对这个问题的回答。该代码演示了降序排序。
For ordering in ascending order, the ascendingkeyword can be ommitted.
对于升序排序,ascending可以省略关键字。

