Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 27th, 2006, 09:45 PM
manojas@hotmail.com
Guest
 
Posts: n/a
Default Question about aggregating attributes in XML

Hi

I am new to XQuery and i am trying to figure out a way to solve the
following

I have an XML document as shown below



<Root>

<Function Name="foo" Time="1" Count="1">

<Function Name="bar" Time="3" Count="1">

<Event Duration="5"/>

</Function>

</Function>

<Function Name="foo" Time="7" Count="2">

<Function Name="bar" Time="11" Count="2">

<Event Duration="13"/>

</Function>

</Function>

<Function Name="bar" Time="19" Count="3">

<Event Duration="23"/>

</Function>

</Root>



I need the following resultset:



Function Sum(Time) Sum(Duration)

foo 8 (7+1) 0

bar 33 (3+11+19) 41 (5+13+23)



I am not sure how to project out the child nodes value aggregates (the
3rd column in the desired resultset)



Sum(Time) - Represents aggregate of the Time attribute grouped by
Function elements Name attribute

Sum (Duration) - Represents aggregate of the Duration attribute grouped
by Name attribute

of the immediate parent Function.It can be assumed that the Event node
will always have a

Function element as parent as per schema



TIA,

Manoj

 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles