[xquery-talk] group by queries - a more efficient approach
Dmitri.Colebatch at toyota.com.au
Dmitri.Colebatch at toyota.com.au
Fri Aug 1 15:14:28 PDT 2003
Jason,
Thanks for the tip.... problem is that my contrieved example didn't really
show what I need to do. I want to modify the structure more than my
example shows.
Your suggestion does work, but I cant see a way to step from that to having
access to a $book variable - am I right that I do need the for loop to get
access to that?
thanks
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