如何从日期和时间投出时间

时间:2018-01-29 18:21:00

标签: sql-server

我正在尝试仅提取我目前拥有的日期时间格式的时间。到目前为止,这是我的查询。我想只为我正在创建的列提取时间(First_Arrival,Last_Arrival等)

SELECT logon_id,activity_date
,MIN(CASE WHEN activity = 'AsnAssignmentOnSite_evt' THEN occurred END) First_Arrival
,MAX(CASE WHEN activity = 'AsnAssignmentOnSite_evt' THEN occurred END) Last_Arrival
,MIN(CASE WHEN activity = 'OrdActivityComplete_evt' THEN occurred END) First_Completion
,MAX(CASE WHEN activity = 'OrdActivityComplete_evt' THEN occurred END) Last_Completion
,MIN(CASE WHEN activity = 'AsnAssignmentEnRoute_evt' THEN occurred END) First_Enroute
,MAX(CASE WHEN activity = 'AsnAssignmentEnRoute_evt' THEN occurred END) Last_Enroute
FROM activity
GROUP BY logon_id,activity_date
order by ACTIVITY_DATE

0 个答案:

没有答案