group by over different values not known in advance (sequence)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

group by over different values not known in advance (sequence)

Jozef Aerts
Usually, I do my "group by" like:
let $orderedrecords := (
    for $record in $datasetdoc//odm:ItemGroupData
        group by
        $b := $record/odm:ItemData[@ItemOID=$usubjidoid]/@Value,
        $c := $record/odm:ItemData[@ItemOID=$seqoid]/@Value
        return element group {  

i.e. the argument of "group by" is a comma-separated list of values ($b,$c variable values in my case).
Now I do have the case that the number of values over which need to be grouped is not known in advance, but come from a query itself. For example:

let $keyoids := $itemgroup/odm:ItemRef[@KeySequence]/@ItemOID (: returns a sequence :)

So I tried:

... group by $keyoids ...

giving me an error "Grouping variable $keyoids evaluates to more than one item".

I tried a few thing like a "for" after "group by" but failed to find a solution.
Is there a way to do this i.e. do "group by" over a variable number of values?
Maybe the question reduces to transforming a sequence into a comma-separated list as string?

Many thanks in advance,


Check out the vibrant tech community on one of the world's most
engaging tech sites,!
Exist-open mailing list
[hidden email]