A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
Please also check:
CREATE TABLE #Table_Dates
(Wkstn VARCHAR(MAX), Date_Created DATE,Date_HWScan
DATE,Date_SWScan DATE,Date_PatchScan DATE,Date_CheckIn DATE)
INSERT INTO #Table_Dates VALUES
('Wkstn','2021-12-14','2021-12-21','2021-12-01','2021-11-30','2021-11-21')
SELECT Wkstn,MAX(dDate) maxDate
FROM #Table_Dates
UNPIVOT (dDate FOR nDate IN ( Date_Created,Date_HWScan
,Date_SWScan ,Date_PatchScan,Date_CheckIn)) as u
GROUP BY Wkstn
Output:
Regards,
Echo
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.