RE: Joins with groupby (No example in W3 Draft)

 

>I have right now a hard time to understand grouping in XQuery. I came from
the relational database to XQuery. 

Sadly, XQuery's grouping facilities are extremely limited.

It is probably a mistake to think of grouping too much in SQL terms. WIth a
hierarchical data model, grouping turns out to be rather different than it
is in a tabular data model. There is a good discussion of grouping in XML
(written in XSLT terms rather than XQuery terms) at
http://www.jenitennison.com/xslt/grouping. Unfortunately, the main grouping
technique used in XSLT 1.0 (so called Muenchian grouping) relies heavily on
keys, which are not available in XQuery. You have to fall back on what you
can achieve with distinct-values(), and hope that the system implements it
efficiently.
	 
>http://www.w3.org/TR/xquery/#id-grouping has an example about grouping but
just on ONE document. I wonder how this should work on a join.  Is there any
grouping example on a join between two documents?

Have you looked in the XQuery Use Cases document? There are more examples
there, but I don't know if there is one that specifically meets your
requirements.

	 

>Right now I am trying to use grouping in the following SQL statement:

	 

	 

	SELECT

	          wisc_berkeley_tracetime.rID,

	          ip,

	          min

	FROM

	          wisc_berkeley_tracelist INNER JOIN wisc_berkeley_tracetime


	          ON wisc_berkeley_tracelist.rID =
wisc_berkeley_tracetime.rID

	WHERE

	          (wisc_berkeley_tracetime.ndate = '20000801000000')

	          GROUP by wisc_berkeley_tracelist.ip;

I'm afraid it's so long since I used an "inner join" (or anything else) in
SQL that I've quite forgotten what this does.

Regards,

Michael Kay

Received on Wednesday, 16 June 2004 18:27:52 UTC