A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
Hi @RoyB09 ,
Please try the following:
Create Table #std (StudentID INT,StartDate Datetime, ExamDate Datetime, ResultDate Datetime);
GO
INSERT INTO #std VALUES (101,'01/01/2019','01/06/2019','01/07/2019');
INSERT INTO #std VALUES (102,'01/01/2020','01/06/2020','01/07/2020');
INSERT INTO #std VALUES (103,'01/01/2021','01/06/2021','01/07/2021');
SELECT StudentID, DatesFrom, FORMAT(Dates, 'yyyy/MM/dd') AS Dates
FROM
(SELECT StudentID, StartDate, ExamDate, ResultDate FROM #std) as p
UNPIVOT( Dates FOR DatesFrom IN (StartDate, ExamDate, ResultDate)) AS unstd
Thanks!
----------
If the above response is helpful, please "accept as answer" and up-vote it. Thanks!