Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 I desperately need help on this problem please

Author  Topic 

kkmurthy
Starting Member

41 Posts

Posted - 2008-04-30 : 10:35:11
I have project table containing ID field and parentID field.
In this table I have three levels: program, project and taskorder. taskorder is a child of Project and project is child of program.
For example the table looks like below with ID, name and ParentID field :
ID Name parent ID
1 Program14 Null
2 Project1 1
3 Taskorder1 2
4 Taskorder2 2

I have another table survey table which is a child table of Project
table( project.ID= survey.projectID). This table contains the data for scores at the lowest level only ( that is task order in this case)The scoreID has only 3 values:1,2,3

the data in survey table lokks as folows:
projectID monthID questionID scoreID
3 1 1 1
3 1 2 1
3 1 3 2
3 1 4 3
3 1 5 2
4 1 1 1
4 1 2 1
4 1 3 2
4 1 4 3
4 1 5 2


In the above data for the projectID=3(taskordeer1) if I countthe number of 1's,2's and 3's in scoreID and group it for task order1 then I will have
the values as :scoreID count
1 2
2 2
3 1
and for task order2 then I will have
the values as :scoreID count
1 2
2 2
3 1


The question I have is :
In the above scenario how will I roll up the total of taskorder 3 and tasak order 4 into its parent project1 (using query only with out writing procedure and creating another table for totals):
in other words when I roll up for project1
I should get the data as follows for Project1:
the values as :scoreID count
1 4
2 4
3 2

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-30 : 10:41:02
Cross post
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=102013



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -