Hi All,
Kindly help me i have the below data required distinct segment id and with segment order.
Sample code as below
Declare @segmentdetails varchar(500)
DECLARE @TEMP TABLE (Segmentid int,from_airport char(3),to_airport char(3))
insert into @TEMP values(1,'MAA','CDG')
insert into @TEMP values(2,'CDG','CCJ')
insert into @TEMP values(3,'CCJ','TRV')
insert into @TEMP values(4,'TRV','MAA')
select
@segmentdetails =COALESCE(@segmentdetails + '/', '')+from_airport+'/'+to_airport
from @TEMP
select @segmentdetails
Current output : MAA/CDG/CDG/CCJ/CCJ/TRV/TRV/MAA
Desired ouput : MAA/CDG/CCJ/TRV/MAA