January 4, 2013 at 4:50 am
I have table with the following structure and datacreate table #temp (id int not null, refid int)
The refid column refers id column but there are no constraint as such till now.
Suppose the table has data as :-
id refid
1 2
2 NULL
3 NULL
4 3
I want the output as:-
id refid
1 2
2 NULL
4 3
3 NULL
January 4, 2013 at 5:01 am
unless you have a way of telling SQL the order, then you can only order on what you have so that would be the id or the refid.
January 4, 2013 at 5:02 am
Hi,
So just to confirm,
this is a parentt-child hierarchy and you wish to start at leaf nodes and work back to root ?
What would you expext to happen if the row , (5,2) were added to the data ?
January 4, 2013 at 6:24 am
Thank you Dave for your reply, if it is 5,2 then it would be aftere 1,2. I think you have rightly pointed it should be like the parent-child query. I'm trying to figure out the query.
Thanks
Arun
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply