需要帮助转动某些数据
SELECT
[contact_list_name] as 'Table'
,[ov_number_dialed] as 'Number Dialed'
,convert(date, [time_of_contact], 101) as 'Date'
,convert(time, dateadd(hour, -7,[time_of_contact]), 108) as 'Time'
,agent_full_name as 'Agent'
,[response_status] as 'Disp'
FROM
[meldb].[dbo].[cl_contact_event]
给我这样的结果:
我想转出或显示结果,以便disp位于
之类的行中
有什么想法?
答案 0 :(得分:1)
根据您的评论,一种简单的转化方式是将max
与case
一起使用:
select
[contact_list_name] as 'Table'
, [ov_number_dialed] as 'Number Dialed'
, convert(date, [time_of_contact], 101) as 'Date'
, convert(time, dateadd(hour, -7,[time_of_contact]), 108) as 'Time'
, agent_full_name as 'Agent'
, max(case when [response_status] = 'DAM' then response_status end) as 'Disp1_DAM'
, max(case when [response_status] = 'DNA' then response_status end) as 'Disp2_DNA'
...
FROM [meldb].[dbo].[cl_contact_event]
GROUP BY
[contact_list_name]
, [ov_number_dialed]
, convert(date, [time_of_contact], 101)
, convert(time, dateadd(hour, -7,[time_of_contact]), 108)
, agent_full_name