Jump to navigation Jump to search
666 bytes added ,  20:23, 30 October 2014
FLWOR expressions have been extended to include the [ group by] clause, which is well-established among relational database systems. <code>group by</code> can be used to apply value-based partitioning to query results:
<pre class="brush:xquery">
for $ppl in doc('xmark')//people/person
order by $income
return element { $income } { count($ppl) }
return element { $income } { $ppl }
<pre class="brush:xml">
Moreover, a value can be assigned to the grouping variable. This is shown in the following example:
<pre class="brush:xquery">
let $data :=
<person country='USA' name='John'/>
<person country='USA' name='Jack'/>
<person country='Germany' name='Johann'/>
for $person in $data/person
group by $country := $person/@country/string()
return element persons {
attribute country { $country },
$person/@name ! element name { data() }
<pre class="brush:xml">
<persons country="USA">
<persons country="Germany">
Bureaucrats, editor, reviewer, Administrators


Navigation menu