Hi I have this table [code="sql"]CREATE TABLE [dbo].[GroupS]( [Id] [int] NULL, [Title] [nvarchar](255) NULL, [ParentId] [int] NULL, [ParentTitle] [nvarchar](255) NULL, [ParentLevel] [tinyint] NULL) ON [PRIMARY]GOInsert into Groups(id,title,parentid,parentTitle,ParentLevel) Values (1,'Group1',Null,Null,0), (2,'Group2',Null,Null,0), (3,'Group3',Null,Null,0), (4,'Group4',Null,Null,0), (5,'Group5',4,'Group4',1), (10,'TenthGroup',1,'Group1',1), (10,'TenthGroup',2,'Group2',2), (10,'TenthGroup',3,'Group3',3), (9 ,'NinetheGroup',4,'Group4',1), (9 ,'NinetheGroup',5,'Group5',2)[/code]I want a pivot View with this output :Id ---- Title ----- ParentIdLevel1 ---- ParentTitleLevel1 ----- ParentIdLevel2 ---- ParentTitleLevel2 ----- ParentIdLevel3 ---- ParentTitleLevel31 Group1 Null Null Null Null Null Null 2 Group2 Null Null Null Null Null Null 3 Group3 Null Null Null Null Null Null 4 Group4 Null Null Null Null Null Null 5 Group5 4 Group4 Null Null Null Null 9 NinetheGroup 1 Group1 2 Group2 3 Group310 TenthGroup 4 Group4 5 Group5 Null NullThe Problem is :I have 2 values ([ParentId] , [ParentTitle) that should be under 2 Pivot Columns (ParentIdLevelX ---- ParentTitleLevelX).
↧