I have raw data that looks as follows:

I want to perform a T-SQL query to put the data in the following form:

It’s almost like an UnPivot type query, but I don’t know how to go about doing it. Also, one clarification. The value for the LastModifiedTime column can be any one of the five values for each SubGroupId. It wouldn’t matter exactly which one it was.
Thanks very much for your help.
There are two ways you can do this, either using a Static PIVOT where you hard code the values in that you need to PIVOT:
Or you can do this via a dynamic Pivot where you create the list of columns on the fly and then PIVOT them: