On Tue, Jan 7, 2014 at 11:29 AM, Ihe Onwuka <ihe.onw...@gmail.com> wrote:

> Tried that already but that will give me a let that follows a group by
> which is not allowed so I put the return back.
>
> When I moved the count up before the group by (still with no return) to
> counter that eXist gave me
>
>
when I moved the let statement up before the group ........

>
> err:XPDY0002 variable '$count' is not set. [at line 11, column
>
>
> On Tue, Jan 7, 2014 at 11:20 AM, Michael Kay <m...@saxonica.com> wrote:
>
>> 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 <ihe.onw...@gmail.com> 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>
>>
>>
>>
>>
>>
>> _______________________________________________
>> talk@x-query.com
>> http://x-query.com/mailman/listinfo/talk
>>
>>
>>
>> _______________________________________________
>> talk@x-query.com
>> http://x-query.com/mailman/listinfo/talk
>>
>
>
_______________________________________________
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

Reply via email to