Question

I've been asked to query a time logging database, to display all the work done for given projects. Each project is broken into tasks, each of which may itself be broken into tasks. The task hierarchy can be an arbitrary number of levels deep. Part of the requirement is to provide total time worked for each task or node in the hierarchy (not just the leaf level nodes but all nodes, including the top level project node, the leaf level nodes and all nodes in between).

Working with such a hierarchy I assume it may be useful to use the HIERARCHYID data type. Is there any way of doing something like a SUM with ROLLUP on a hierarchy, to give the sub-totals for each node in the hierarchy?

I assumed this sort of aggregate rollup on a hierarchy would be a common requirement but I've had no luck at all finding how to do it, or even if it is possible.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top