M
manojas
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
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