|
JohnBGood
Starting Member
48 Posts |
Posted - 2009-09-02 : 21:42:14
|
| I have project data in two tables. The first table contains time-phased ‘assignments’ at the lowest level and looks something like this.AssignmentID,TimeByDay,TaskName,TaskID,Cost1,1/1/2009, 'Write UI Spec', 3, 51,1/2/2009, 'Write UI Spec', 3, 51,1/3/2009, 'Write UI Spec', 3, 51,1/4/2009, 'Write UI Spec', 3, 52,1/1/2009, 'Write Data Spec', 4, 52,1/2/2009, 'Write Data Spec', 4, 53,1/1/2009, 'Build Screen Mockups', 6, 53,1/2/2009, 'Build Screen Mockups', 6, 5 4,1/1/2009, 'Build Engine Mockups', 7, 54,1/2/2009, 'Build Engine Mockups', 7, 5 the taskID (column 4) maps to taskID in table 2, which looks like the following:TaskID,TaskName,ParentID1, 'Design', null2,'Write Specifications', 13,'Write UI Spec', 24,'Write Data Spec', 25,'Build Mockups', 16,'Build Screen Mockups', 57,'Build Engine Mockups', 5Note how the parentID defines the hierarchy of tasks. For example, 'Write UI Spec' has a Parent Task of 'Write Specifications', which has a parent of ‘Design’.I want to return data that returns the total cost for each task. Something like1, 'Design', null, 502,'Write Specifications', 1, 303,'Write UI Spec', 2, 204,'Write Data Spec', 2, 105,'Build Mockups', 1, 206,'Build Screen Mockups', 5, 107,'Build Engine Mockups', 5, 10I want to use a CTE but cant get my head around the syntax. Any help much appreciated!! |
|