may also done without sub query but i gave my tryCREATE TABLE #temp(CatId int,Name varchar(1024),ParentCatId int)INSERT INTO #tempSELECT 1,'Automobile',0 UNION ALLSELECT 2 ,'Communications',0 UNION ALLSELECT 3 ,'Bikes',1 UNION ALLSELECT 4 ,'Cars',1 UNION ALLSELECT 5 ,'Vodafone',2SELECT t1.catId ,t1.name ,CASE WHEN t1.ParentCatid = 0 THEN 'Parent' ELSE (SELECT name FROM #temp WHERE catID = t1.ParentCatId) END AS Parent FROM #temp AS t1LEFT JOIN #temp AS t2ON t1.Catid = t2.CatidDROP TABLE dbo.#temp
---------------Murali KrishnaYou live only once ..If you do it right once is enough.......