T-SQL QUERY PROBLEM
- by Sam
Hi All,
I have table called Summary and the data in the table looks like this:
ID Type Name Parent
1 Act Rent Null
2 Eng E21-01-Rent Rent
3 Prj P01-12-Rent E21-Rent
1 Act Fin Null
2 Eng E13-27-Fin Fin
3 Prj P56-35-Fin E13-Fin
I am writing a SP which has to pull the parent based on type. Here always the type Act has ID 1, Eng has ID 2 and Prj has ID 3.
The type ACT parent is always NUll,
type Eng parent is Act and
type Prj parent is Eng
Now I have table called Detail.I am writing a SP to insert Detail Table data to the Summary table.
I am passing the id as parameter:
I am having problem with the parent. How do I get that?
I can always say when ID is 1 then parent is Null but when ID is 2 then parent is name of ID 1 similarly when ID is 3 then parent is name of ID2.
How do I get that?
Can anyone help me with this: