Skip to content

Instantly share code, notes, and snippets.

@CliffordAnderson
Created February 18, 2015 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save CliffordAnderson/0d25fcd4de6e05c85f36 to your computer and use it in GitHub Desktop.
Save CliffordAnderson/0d25fcd4de6e05c85f36 to your computer and use it in GitHub Desktop.
Order by & Group by in XQuery
let $books :=
<books>
<book class="fiction">Book of Strange New Things</book>
<book class="nonfiction">Programming Scala</book>
<book class="fiction">Absurdistan</book>
<book class="nonfiction">Art of R Programming</book>
<book class="fiction">I, Robot</book>
</books>
for $book in $books/book
let $title := $book/text()
let $class := $book/@class
order by $title
group by $class
return ($class, $title)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment