[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

RE: aggregate , grouping

fatma helmy fatmahelmy2000 at yahoo.com
Wed Dec 21 10:12:40 PST 2005


select count group by
dear all
as you know in relational data base , we can apply
grouping and count at the same time
example from relational
TID=1  Item=D
TID=1  Item=B
TID=2  Item=C
if Select count(item) group by TID , the result will
be
TID=1 count of items=2
TID=2 count of items=1
i need the same in xquery , if i have xml file, i need
to get the elements names found in the document
described by their full path then i need to count the
number of repetition of each node in the document.
each node must be described by its full path as i
declared in the example




--- Michael Kay <http://xquery.com/mailman/listinfo/talk> wrote:

>  
> > Grouping is a bit convoluted in XQuery 1.0. I
> assume here 
> > that by "distinct" you mean "having distinct
> values of the 
> > @id attribute".
> > 
> > You can select the first <trans> element having
> each distinct id using
> > 
> > for $i in distinct-values(trans/@id)
> > return trans[@id=$i][1]
> > 
> > But it's not clear to me from your problem
> description what 
> > you then want to do with these elements.
> > 
> > Michael Kay
> > http://www.saxonica.com/ 
> > 
> > > -----Original Message-----
> > > From: fatma helmy
> [mailto:http://xquery.com/mailman/listinfo/talk] 
> > > Sent: 21 December 2005 11:46
> > > To: http://xquery.com/mailman/listinfo/talk
> > > Subject: aggregate , grouping
> > > 
> > > Dear all
> > > suppose i have xml like
> > > <trans id=1>
> > >    <item>
> > >         <elem> it </elem>
> > >    </item>
> > > </trans>
> > > <trans id=2>
> > >    <item>
> > >         <elem> is </elem>
> > >    </item>
> > > </trans>
> > > 
> > > i need to slect distint nodes such that i can
> > > automatically get the node names which are
> <trans> ,
> > > <item> , <elem> 
> > > and also i want to keep the path they came from
> for
> > > exammple node elem is in the path trans/item/
> > > then i need aggregate function which produces
> the
> > > count of certain pathfor example . path
> item/elem  is
> > > repeated twice in trans 1 and trans 2
> > > 
> > > thanks
> > > 
> > > 
> > > 
> > >
> __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> > > http://mail.yahoo.com 
> > > 
> > 
> 
> 
> _______________________________________________
> http://xquery.com/mailman/listinfo/talk
> http://xquery.com/mailman/listinfo/talk
> 




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.