Hi,I have a table that each row related to another row, and apart from that they have nothing in common.[code="sql"]create table #mynumbers (Appl int, Pre_App int);insert into #mynumbers (Appl, Pre_App) values (58672235, 0);insert into #mynumbers (Appl, Pre_App) values (58791134, 58672235);insert into #mynumbers (Appl, Pre_App) values (58800760, 58791134);insert into #mynumbers (Appl, Pre_App) values (58993700, 0);insert into #mynumbers (Appl, Pre_App) values (59068028, 58993700);insert into #mynumbers (Appl, Pre_App) values (59139976, 59068028);insert into #mynumbers (Appl, Pre_App) values (59200408, 59139976);select * from #mynumbers[/code]I would like to query it in a way that a column will be added with the appl number. that number is the one that the pre_app = 0in this case the original appl would be 58672235 and 58993700.how can i loop the data?thanksastrid
↧