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.
| Author |
Topic |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2010-03-25 : 12:18:38
|
Hi thereI am working with a certain I have inherited with following structureProject# Ref#1 222 222 222 222 First row with project# is the 'parent' row all children rows are figured out by looking at any rows with project# blank but Ref# equal to parent row, since parent row has Project# no blank. Sort of self referencing table. What I am trying to do is do a self join so that I can get parent row tables, but I want to on the fly give the children rows parent rows project#. How do I got about doing that?Thank you<><><><><><><><><><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-25 : 12:23:21
|
| [code]select t.[Ref#],t1.[Project#]from yourtable tjoin yourtable t1on t1.[ref#] = t.[ref#]and t1.[Project#] is not null[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2010-03-26 : 18:00:41
|
| right on the money! thanks V<><><><><><><><><><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-27 : 02:03:22
|
welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|