我遇到了根据相应的总结代码将数据分组的挑战。
我有一个看起来像截图A的视图,我的尝试导致截图B实际上我的结果需要返回截图C.
简而言之,我需要将NULLS分组到SegmentType Interact + hold + wrap组成一个调用的相应最终结果
提前为帖子格式道歉。
屏幕截图A
屏幕截图B
屏幕截图C
Code Examaple
SELECT TOP 1000
vw_Conversations.direction
,vw_Conversations.conversationId
,vw_Conversations.username
,vw_Conversations.conversationStart
,vw_Conversations.wrapUpCode
,DATEDIFF_BIG(MILLISECOND, vw_Conversations.segmentStart, vw_Conversations.segmentEnd) AS Duration
FROM dbo.vw_Conversations
WHERE vw_Conversations.purpose = 'user'
OR vw_Conversations.purpose = 'agent'
AND vw_Conversations.segmentType <> 'alert'
GROUP BY vw_Conversations.direction
,vw_Conversations.username
,vw_Conversations.wrapUpCode
,vw_Conversations.conversationStart
,DATEDIFF_BIG(MILLISECOND, vw_Conversations.segmentStart, vw_Conversations.segmentEnd)
,vw_Conversations.conversationId