You need to cut out that middle "return". You've written two nested FLWOR 
expressions, and an "order by" clause on the inner FLWOR expression isn't going 
to affect the order of the outer FLWOR expression.

Michael Kay
Saxonica

On 7 Jan 2014, at 10:47, Ihe Onwuka <[email protected]> wrote:

> 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>
> 
> 
> 
> 
> 
> _______________________________________________
> [email protected]
> http://x-query.com/mailman/listinfo/talk

_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk

Reply via email to