I am most distressed that this worked, firstly section 3.10.8 of the spec says
An order by clause contains one or more ordering specifications, called orderspecs <http://www.w3.org/TR/xquery-30/#doc-xquery30-OrderSpec>, as shown in the grammar. For each tuple in the input tuple stream, the orderspecs are evaluated, using the variable bindings in that tuple. but for that query to have worked it must have applied the orderspec to each tuple in the post-grouping tuple stream. It also suggests that the count($thing) has to be evaluated twice (in the order by and the return - perhaps this gets optimised) because of the prohibition of the let - following the group by. So it worked, but I'm still baffled. section 3.10.8 of the spec says On Tue, Jan 7, 2014 at 12:05 PM, Michael Kay <[email protected]> wrote: > Try > > <counts>{ > for $thing in > subsequence(collection($sp:reviewsColl)/descendant::reviews[1]//thing,1,50000) > group by $name:=$thing/@name > order by count($thing) descending > > return <thing name="{$name}" count="count($thing)}" />} > > </counts> > > > Michael Kay > Saxonica > > > On 7 Jan 2014, at 11:34, Ihe Onwuka <[email protected]> wrote: > > <counts>{ > for $thing in > subsequence(collection($sp:reviewsColl)/descendant::reviews[1]//thing,1,50000) > group by $name:=$thing/@name > return > let $count:=count($thing) > order by $count descending > return <thing name="{$name}" count="{$count}" />} > </counts> > > > > _______________________________________________ > [email protected] > http://x-query.com/mailman/listinfo/talk >
_______________________________________________ [email protected] http://x-query.com/mailman/listinfo/talk
