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
 Hiearchy forming

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2013-06-03 : 21:01:12
Hi can anyone help to get the desired output:

My Actual table is:


Classification Train Station Industry Key Customer Descr

RE XX 1Z 142085 CustomerA
RE XX 1P 142079 CustomerB



Desire output table should be:

Parent Child descr
RE XX null
RE XX null
XX 1Z null
XX 1P null
1Z 142085 customerA
1P 142079 customerB

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-06-03 : 23:27:16
[code]
select [Classification] as Parent, [Train] as Child, NULL as descr from [My Actual table]

union all

select [Train] as Parent, [Station] as Child, NULL as descr from [My Actual table]

union all

select [Station] as Parent, [Industry Key] as Child, [Customer Descr] as descr from [My Actual table]

[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -