Refer below query.
SQL
DECLARE @Test AS TABLE(ID INT,Name VARCHAR(50),Status TINYINT)
INSERT INTO @Test VALUES(58,'/parentlogin',1)
INSERT INTO @Test VALUES(59,'/teacherlogin',1)
INSERT INTO @Test VALUES(60,'/studentregistration',0)
INSERT INTO @Test VALUES(61,'/parentregistration',0)
INSERT INTO @Test VALUES(62,'/teacherregistration',0)
SELECT *
FROM(
SELECT Id,Name,[Status]
FROM @Test
) p
PIVOT
(
MAX([Name]) FOR [Status] IN ([0],[1])
) pvt
Output
Id |
0 |
1 |
58 |
NULL |
/parentlogin |
59 |
NULL |
/teacherlogin |
60 |
/studentregistration |
NULL |
61 |
/parentregistration |
NULL |
62 |
/teacherregistration |
NULL |