Skip to content

Instantly share code, notes, and snippets.

@mblakele
Created November 6, 2011 01:00
Show Gist options
  • Save mblakele/1342287 to your computer and use it in GitHub Desktop.
Save mblakele/1342287 to your computer and use it in GitHub Desktop.
W3C XQuery 3.0 - Group By Use Cases Q2
<result>{
for $sales in doc("sales-records.xml")/*/record
let $state := doc("stores.xml")/*/store[store-number = $sales/store-number]/state
let $category := doc("products.xml")/*/product[name = $sales/product-name]/category
group by $state, $category
order by $state, $category
return
<group>
{$state, $category}
<total-qty>{sum($sales/qty)}</total-qty>
</group>
}</result>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment