我有以下 2 个程序用作报告的来源。截至目前,我在我的 SQL Server Reporting Services 2008 R2 报告中展示了 2 个不同的表,因为它不允许我将它们放在一起,因为它们属于 2 个不同的数据集。
我想将它们呈现在一个表中,但我在这里尝试使用 JOIN 并没有成功。我怎么做?
注意:cName
inIAgentQueueStats
对应于UserId
in AgentActivityLog
。
/*** Aggregate values for Call Center Agents for calls, talk and hold time ***/
/*** The detail/row values is per 30-minute interval ***/
ALTER PROCEDURE [dbo].[sp_IAgentQueueStats_OnlyCalls_Grouped]
@p_StartDate datetime,
@p_EndDate datetime,
@p_Agents varchar(8000)
AS
SELECT [cName]
,sum([nAnswered]) SumNAnswered
,sum([nAnsweredAcd]) SumNAnsweredAcd
,sum([tTalkAcd]) SumTTalkAcd
,sum([nHoldAcd]) SumNHoldAcd
,sum([tHoldAcd]) SumTHoldAcd
,sum([tAcw]) SumTAcw
FROM [I3_IC].[dbo].[IAgentQueueStats]
WHERE dIntervalStart between @p_StartDate and DATEADD(s, 86400-1, @p_EndDate)
AND CHARINDEX ( cName ,@p_Agents)> 0
AND cReportGroup <> '*'
AND cHKey3 = '*' and cHKey4 ='*'
AND nEnteredAcd > 0
AND cReportGroup <> 'CCFax Email'
GROUP BY cName
这是第二个:
/*** Aggregate values for Call Center Agents for status/activity time ***/
/*** The detail/row values is per start-time/end-time ***/
ALTER PROCEDURE [dbo].[sp_AgentActivity_Grouped]
@p_StartDate datetime,
@p_EndDate datetime,
@p_Agents varchar(8000)
AS
SELECT [UserId],[StatusCategory],SUM([StateDuration]) [StatusDuration] FROM
(
SELECT
[UserId]
,[StatusGroup]
,[StatusKey]
, CASE [StatusKey]
WHEN 'Available' THEN 'Productive'
WHEN 'Follow Up' THEN 'Productive'
WHEN 'Campaign Call' THEN 'Productive'
WHEN 'Awaiting Callback' THEN 'Productive'
WHEN 'In a Meeting' THEN 'Not Your Fault'
WHEN 'Project Work' THEN 'Not Your Fault'
WHEN 'At a Training Session'THEN 'Not Your Fault'
WHEN 'System Issues' THEN 'Not Your Fault'
WHEN 'Test' THEN 'Not Your Fault'
WHEN 'At Lunch' THEN 'Non Productive'
WHEN 'Available, Forward' THEN 'Non Productive'
WHEN 'Available, Follow-Me' THEN 'Non Productive'
WHEN 'At Play' THEN 'Non Productive'
WHEN 'AcdAgentNotAnswering' THEN 'Non Productive'
WHEN 'Do Not Disturb' THEN 'Non Productive'
WHEN 'Available, No ACD' THEN 'Non Productive'
WHEN 'Away from desk' THEN 'Non Productive'
ELSE [StatusKey]
END StatusCategory
,stateduration
FROM [I3_IC].[dbo].[AgentActivityLog]
WHERE [StatusDateTime] between @p_StartDate and DATEADD(s, 86400-1, @p_EndDate)
AND CHARINDEX ( [UserId] ,@p_Agents)> 0
AND [StatusKey] not in ('Gone Home','Out of the Office','On Vacation','Out of Town')
) a
GROUP BY [UserId],[StatusCategory]
ORDER BY [UserId], [StatusCategory] desc
顺便说一句,如果我花一些时间来评论/回复您的帖子,那不是缺乏兴趣,而是缺乏理解……
这是我想要的报告: Rows: Person (= cName
in IAgentQueueStats
= UserId
in AgentActivityLog
)
列:来自IAgentQueueStats
:
sum([nAnswered])
sum([nAnsweredAcd])
sum([tTalkAcd])
sum([nHoldAcd])
sum([tHoldAcd])
sum([tAcw])
从AgentActivityLog
总数是'Productive'
总数是'Not Your Fault'
总数是'Non Productive'
但请注意'Productive'
,'Not Your Fault'
和'Non Productive'
是在行中重复的值,AgentId
这意味着许多具有相同AgentId
和值的行,必须总计并“转换”为一列。
这很复杂,我相信...