[xquery-talk] group by queries - a more efficient approach

Dmitri.Colebatch at toyota.com.au Dmitri.Colebatch at toyota.com.au
Fri Aug 1 17:41:06 PDT 2003


Jason,

I cant remember if I replied to this or not.

Your change works fine, but if I want to in fact change the structure of
the xml I would need the flowr expression yes?

In any case, thanks a heap for your help.

cheers
dim





Jason Hunter <jhunter at servlets.com>@x-query.com on 01/08/2003 01:58:53 PM

Sent by:    talk-bounces at x-query.com


To:    Dmitri.Colebatch at toyota.com.au
cc:    talk at x-query.com
Subject:    Re: [xquery-talk] group by queries - a more efficient approach

> for $s in distinct-values($this/mydata/book/subject)
> return
>       <books-by-subject>
>       {
>             for $book in $this/mydata/book[subject/text() = $s/text()]
>                   return
>                         <book>
>                               <name>{$book/name}</name>
>                               <subject>{$book/subject}</subject>
>                         </book>
>       }
>       </books-by-subject>

I suspect something like this would work.  I haven't run it or anything.
  Basically you can remove the /text() node tests and can return the
book nodes directly without needing a FLWOR.

for $s in distinct-values($this/mydata/book/subject)
return
       <books-by-subject>
       {
             $this/mydata/book[subject = $s]
       }
       </books-by-subject>

-jh-


_______________________________________________
talk at x-query.com
http://www.x-query.com/mailman/listinfo/talk



- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                               DISCLAIMER
* This email and any attachment may contain confidential information.
  If you are not the intended recipient you are not authorised to copy
  or disclose all or any part of it without the prior written consent
  of Toyota.
* Opinions expressed in this email and any attachment are those of the
  sender and not necessarily the opinions of Toyota.
* Please scan this email and any attachment for viruses.  Toyota does
  not accept any responsibility for problems caused by viruses, whether
  it is Toyota's fault or not.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -




More information about the talk mailing list