1
kudos
spam Kudos Remove

Explanation of my winning solution to TSQL Challenge 19 - Dave Ballantyne's Blog

published 715 days, 8 hours, 31 minutes ago posted by jacobsebastianjacobsebastian 725 days, 8 hours, 10 minutes ago
Tuesday, June 08, 2010 11:29:22 AM GMT Saturday, May 29, 2010 11:50:42 AM GMT

I have received a number of requests for an explanation of my winning query of TSQL Challenge 19. This involved traversing a hierarchy of employees and rolling a count of orders from subordinates up to superiors.

The first concept I shall address is the hierarchyId , which is constructed within the CTE called cteTree. cteTree is a recursive cte that will expand the parent-child hierarchy of the personnel in the table @emp. One useful feature with a recursive cte is that data can be ‘passed’ from the parent to the child data. The hierarchyId column is similar to the hierarchyId data type that was introduced in SQL Server 2008 and represents the position of the person within the organisation.

category: Query | clicked: 0 | | source: beyondrelational.com | show counter code

No comments yet, be the first one to post comment.

To post your comment please login or signup