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
 General SQL Server Forums
 New to SQL Server Programming
 Regarding leaf and parent level data need from qu

Author  Topic 

mailtosaja
Starting Member

28 Posts

Posted - 2008-10-30 : 07:05:49
hi,
i have the two table like below.

masterdetails(table name)

id_1 |id_parent_id|i_root_id|
1001 |1001 |1001
1002 |1001 |1001
1003 |1002 |1001
1004 |1003 |1001
1006 |1003 |1001
1005 |1002 |1001

and [employee time]table name
id_1 |timespent
1004 |7
1006 |8
1005 | 6

i would like to display the result below

1001 21
1002 21
1003 15
1004 7
1005 6
1006 8

it's look like leaf level and parent level.help me..


Thanks & Regards,
S.Sajan.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-30 : 07:24:43
Are you using sql 2005? if yes make use of recursive CTE to solve this. you can search within these forums. there are lots of posts
Go to Top of Page

mailtosaja
Starting Member

28 Posts

Posted - 2008-10-30 : 07:49:21
hi,
Thanks for your reply..Can you give me the details form me..
Thanks & Regards,
S.Sajan.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-30 : 08:03:10
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=93830&SearchTerms=recursive,query
Go to Top of Page
   

- Advertisement -