Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8923947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:16:01+00:00 2026-06-15T07:16:01+00:00

I have a query that ranks call centers based on a couple of performance

  • 0

I have a query that ranks call centers based on a couple of performance metrics. I am attempting to modify this query by adding in the number of surveys each center received.

After adding the “Total” or “Surveys” column in the appropriate places, I am receiving the error:

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

Can you tell me where I am mis-defining the column? I will post the relevant parts of the code:

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)

“…” denotes a chunk of code I deleted due to irrelevance. Please let me know if I have not posted enough. I can post more but heard complaints about posting too much in the past.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:16:02+00:00Added an answer on June 15, 2026 at 7:16 am

    Execute this code and then try again:

    DROP TABLE #ACSResults 
    DROP TABLE #HRRep
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that creates a result set like this: Rank Name 1
I have have this query that i want to execute. SELECT warehouse.expiry_date, pharmacy.expiry_date, drugs.active_substance,
I have this query that returns the results by ordering it by focus.name ASC.
I have a query that looks like this SELECT * from myTable WHERE Date
I have a mysql query that pulls into excel via an ODBC connection. This
I have a MySQL query called $sqlStr5 that ranks rows by a metric called
I have a SQL query that does some ranking, like this: SELECT RANK() OVER(PARTITION
I am using in C# MYsql .I have query that works if I run
I have a query that successfully grabs the unique products from my products table
I have a query that basically combines tables of actions and selects from them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.