CREATE table #yourtable ([Id] int, [CrewName] varchar(15)...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Craft CMS Meta

Q&A about the site for administrators, end users, developers and designers for Craft CMS

CREATE table #yourtable
([Id] int, [CrewName] varchar(15), [EventTime] datetime, [EventCaption] varchar(25))
;
    
INSERT INTO #yourtable
    ([Id], [CrewName], [EventTime], [EventCaption])
VALUES
    (1, 'S Stark', '2021-10-25 13:55:00.000', 'Assigned to outage'),
    (1, 'S Stark', '2021-10-25 14:00:00.000', 'Leaving Home'),
    (1, 'S Stark', '2021-10-25 14:15:00.000', 'Arrived on site')
;


select 'Assigned to outage', 'Leaving Home', 'Arrived on site'
from
(
  select CrewName, EventTime, EventCaption
  from #yourtable
) d
pivot
(
  max(EventTime)
  for EventCaption in (Firstname, Amount, PostalCode, LastName, AccountNumber)
) piv;

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results