0

我有一个查询,它根据几个性能指标对呼叫中心进行排名。我试图通过添加每个中心收到的调查数量来修改此查询。

在适当的位置添加“总计”或“调查”列后,我收到错误:

Insert Error: Column name or number of supplied values does not match table definition.

你能告诉我我在哪里错误定义了列吗?我将发布代码的相关部分:

IF OBJECT_ID('tempdb..#ACSResults') 
IS NOT NULL DROP TABLE #ACSResults 
CREATE TABLE #ACSResults (AreaID VARCHAR(4), Location VARCHAR(50), Surveys VARCHAR(6), MonthName VARCHAR(6), RepResolve FLOAT, ERP FLOAT)
INSERT INTO #ACSResults 
      SELECT 
        a.area,
        a.location,
        COUNT(a.IVRCallID) as Surveys,
        a.monthname,
        CASE WHEN SUM(CASE WHEN a.RepResolve IN ('1','0') THEN 1 ELSE 0 END) = 0 THEN NULL ELSE CAST(SUM(CASE WHEN a.RepResolve = '1' THEN 1 ELSE 0 END)AS FLOAT) / CAST(SUM(CASE WHEN a.RepResolve IN ('1','0') THEN 1 ELSE 0 END) AS FLOAT) END AS REPRESOLVE,
        CASE WHEN SUM(CASE WHEN a.ERP IN ('0','1','2','3','4','5','6','7','8', '9', '10') THEN 1 ELSE 0 END) = 0 THEN NULL ELSE (CAST(SUM(CASE WHEN a.ERP IN ('8', '9', '10') THEN 1 ELSE 0 END) AS FLOAT) / CAST(SUM(CASE WHEN a.ERP in ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10') THEN 1 ELSE 0 END) AS FLOAT))END AS ERP

FROM (SELECT
... 
acs.IVRCallID, 
...

FROM dbCustomerSurvey.Detail.vwAfterCallSurvey acs 
LEFT JOIN dbEmployee.Summary.vwEmployeeHistory eh ON acs.EmployeeID = eh.EmployeeID AND acs.OfferDate BETWEEN eh.StartDate AND eh.EndDate 
LEFT JOIN dbEmployee.Config.vwName Rep ON eh.EmployeeID = Rep.EmployeeID 
LEFT JOIN dbEmployee.Config.vwName Sup ON eh.BottomUp01ID = Sup.EmployeeID
LEFT JOIN dbEmployee.Config.vwName Mgr ON eh.BottomUp02ID = Mgr.EmployeeID
LEFT JOIN dbEmployee.Config.vwName Dir ON eh.BottomUp03ID = Dir.EmployeeID
LEFT JOIN dbEmployee.Config.vwVirtualLocation vl ON eh.VirtualLocationID = vl.VirtualLocationID 
LEFT JOIN dbEmployee.Config.vwDepartment d ON eh.DepartmentID = d.DepartmentID 
LEFT JOIN dbEmployee.Config.vwPeopleSoftDepartment psd ON eh.PeopleSoftDepartmentID = psd.PeopleSoftDepartmentID
WHERE acs.CurrentStatus IN ('Completed', 'COMP') and acs.surveytype IN ('ACS_FCR_Rep_Perform', 'ACS_FCR_Rep_Perform-prepaid', 'ACS_Rep_Perform_BSC2', 'ACS_Rep_Perform_Gov') AND acs.OfferDate Between @StartDate AND @EndDate) a 

...

group by 
a.area,
a.location,
a.monthname

--------------------------------------------------------------------------------REPEAT TABLE------------------------------------------------------------------------------------------------------
IF OBJECT_ID('tempdb..#HRRep') 
IS NOT NULL DROP TABLE #HRRep 
CREATE TABLE #HRRep (AreaID VARCHAR(4), Location VARCHAR(50), Surveys VARCHAR(6), MonthName VARCHAR(6), HourRepeatPercent FLOAT)
INSERT INTO #HRRep (AreaID, Location, Surveys, MonthName, HourRepeatPercent) 
      Select eh.AreaID, vl.VirtualLocationDescription, COUNT(acs1.IVRCallID) as Surveys, Month (acs.statdate) AS MonthName,

Cast(Sum(acs.Repeats2Hr)as float) /nullif(Sum(acs.Calls2Hr), 0) as 'HourRepeatPercent'

From dbReportSummary.ReportSummary.vwRepeatCalls2Hr acs with (NoLOCK)
LEFT JOIN dbEmployee.Summary.vwEmployeeHistory eh with (NoLOCK) ON acs.EmployeeID = eh.EmployeeID AND acs.StatDate BETWEEN eh.StartDate AND eh.EndDate 
LEFT JOIN dbEmployee.Config.vwVirtualLocation vl ON eh.VirtualLocationID = vl.VirtualLocationID 
LEFT JOIN dbEmployee.Config.vwDepartment d ON eh.DepartmentID = d.DepartmentID 
LEFT JOIN dbEmployee.Config.vwPeopleSoftDepartment psd ON eh.PeopleSoftDepartmentID = psd.PeopleSoftDepartmentID
LEFT JOIN dbCustomerSurvey.Detail.vwAfterCallSurvey acs1 ON acs.EmployeeID=acs1.EmployeeID and acs1.OfferDate BETWEEN @StartDate and @EndDate

...

Group by eh.AreaID, vl.VirtualLocationDescription, Month (acs.statdate)


SELECT a.Location, a.Surveys, a.RepResolve, a.RRRank, a.ERP, a.ERPRank,a.HourRepeatPercent, a.RepeatRank, (a.RRRank + a.ERPRank+a.RepeatRank) as 'Total Rank Points', Rank() OVER(ORDER BY (a.RRRank + a.ERPRank+a.RepeatRank) ASC, a.RepResolve DESC) AS 'Overall Rank'
From(
            SELECT a.Location, a.Surveys, a.RepResolve, Rank() OVER(ORDER BY a.RepResolve DESC) AS RRRank, a.ERP, Rank() OVER(ORDER BY a.ERP DESC) AS ERPRank, b.HourRepeatPercent, Rank() OVER(ORDER BY b.HourRepeatPercent ASC) AS RepeatRank
            FROM #ACSResults AS A
            Left Join #HRRep AS B on a.areaid=b.areaid and a.monthname=b.monthname and a.location=b.location and a.Surveys=b.Surveys
) a
Group BY  a.Location, a.Surveys, a.RepResolve, a.RRRank, a.ERP, a.ERPRank,a.HourRepeatPercent, a.RepeatRank, (a.RRRank + a.ERPRank+a.RepeatRank)

“...” 表示由于不相关而删除的一段代码。如果我发布的内容不够多,请告诉我。我可以发布更多信息,但听说过去发布过多的投诉。

4

1 回答 1

1

执行此代码,然后重试:

DROP TABLE #ACSResults 
DROP TABLE #HRRep
于 2012-11-28T19:10:35.557 回答