xquery version "3.0"; The task is to display things in descending order of the number of times they occur.
New Effort import module namespace sp="urn:xxxxxxxxxx.com" at 'common.xqm'; <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> In New Effort, my post-grouping tuple should consist of the grouping key and a sequence of n $things where n is the number of of $thing for that grouping key. I aim to capture that in the let so that I can order by it when outputing. However the ordering does is ineffective and I get the same output as Original effort below which makes no attempt to order. Original Effort xquery version "3.0"; import module namespace sp="urn:xxxxxxxxxxxxxx.com" at 'common.xqm'; <counts>{ for $thing in subsequence(collection($sp:reviewsColl)/descendant::reviews[1]//thing,1,50000) group by $name:=$thing/@name return <thing name="{$name}" count="{count($thing)}" />} </counts>
_______________________________________________ talk@x-query.com http://x-query.com/mailman/listinfo/talk