here's some sample data to try and explain my problem
Input
Code:
<company>
<unit>
<unitno>1111</unitno>
<category>Housewares</categroy>
<employees>2</employees>
<sales>
<periodone>1000</periodone>
<periodtwo>2000</periodtwo>
<periodthree>0</periodthree>
<periodfour>1</periodfour>
</sales>
</unit>
<unit>
<unitno>1111</unitno>
<category>Garden</categroy>
<employees>1</employees>
<sales>
<periodone>400</periodone>
<periodtwo>200</periodtwo>
<periodthree>90</periodthree>
<periodfour>50</periodfour>
</sales>
</unit>
<unit>
<unitno>1111</unitno>
<category>Automotive</categroy>
<employees>3</employees>
<sales>
<periodone>2500</periodone>
<periodtwo>3000</periodtwo>
<periodthree>1680</periodthree>
<periodfour>0</periodfour>
</sales>
</unit>
</company>
Output
periodname sales employees
periodone 3900 6
periodtwo 5200 6
periodthree 1770 4
periodfour 51 3
I have no problem getting the output for the first two columns(periodname,sales). However, if the sales for that period are zero then the employees should be excluded (periodthree, periodfour). I can't figure the way to sum because the predicate that needs to be applied [period1!=0] is a level below the number i want sum(employees). Any help would greatly appreciated!
FYI this is just a sample. In reality the number and name of the children for sales varies. However, I've handled all those issues but this one has me stumped.