Changes

Jump to navigation Jump to search
1,517 bytes added ,  11:26, 13 January 2011
→‎Group By: added example
==Group By==
FLWOR expressions have been extended by the [http://www.w3.org/TR/xquery-30/#id-group-by group by] clause, which is well-established among relational database systems. Group by clauses can be used to group apply value based paritioning to query results based on its values.:
Michi? '''Example:''' <pre class="brush:xquery"> for $ppl in doc('xmark')//people/person let $ic := $ppl/profile/@incomelet $income := if($ic<30000) then "challenge" else if(Example, Details$ic >= 30000 and $ic<100000) then "standard" else if($ic >= 100000) then "prefered" else "na" group by $incomeorder by $incomereturn element {$income} {count($ppl)} </pre>  Is a rewrite of [http://www.ins.cwi.nl/projects/xmark/Assets/xmlquery.txt| Query #20] contained in the [http://www.ins.cwi.nl/projects/xmark|XMARK Benchmark Suite] to use ''group by''.The query partitions the customers based on their income.  '''Result:''' <pre class="brush:xml"><challenge>4731</challenge><na>12677</na><prefered>314</prefered><standard>7778</standard></pre> In contrast to the relational GROUP BY the XQuery counterpartconcatenates the values of all non-grouping variables that belong to a specific group.In the context of our example, all nodes in <code>//people/person</code> that belong to the <code>"preferred"</code> partition are concatenated in <code class="brush:xquery">$ppl</code> after grouping has finished.You can see this effect by changing the return statement to: <pre class="brush:xquery"> return element {$income} {count($ppl)}</pre>'''Result:'''<pre class="brush:xml"><challenge> <person id="person0"> <name>Kasidit Treweek</name> <person id="personX"></challenge></pre>
==Try/Catch==
administrator, Bureaucrats, editor, Interface administrators, reviewer, Administrators
401

edits

Navigation menu