Skip to content

Instantly share code, notes, and snippets.

@mblakele
Created November 6, 2011 00:56
Show Gist options
  • Save mblakele/1342280 to your computer and use it in GitHub Desktop.
Save mblakele/1342280 to your computer and use it in GitHub Desktop.
W3C XQuery 3.0 - Group By Use Cases Q1, using distinct-values
<sales-qty-by-product>{
for $pname in distinct-values(
doc("sales-records.xml")/*/record/product-name)
order by $pname
return
<product name="{$pname}">{
sum(
doc("sales-records.xml")/*/record[
product-name eq $pname ]/qty)
}</product>
}</sales-qty-by-product>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment