나는 두 개의 하위 쿼리에서 결과를 빼기 위해 노력하고 있지만 총 호출 수를보고 싶기 때문에 두 개 이상의 행을 반환하려고합니다. 특정 날짜 범위와 이들의 차이점에 대해 "하위 쿼리가 1 개 이상의 값을 반환했습니다. 하위 쿼리가 =,! =, <, < =,>,> = 또는 when 다음에 오는 경우 허용되지 않습니다. 부속 조회는 표현식으로 사용됩니다. 당신이 날 도와 줄 수 있길 바래. 이 저장 프로 시저의 일부임을 유의하십시오. 미리 감사드립니다.두 행을 반환하는 두 SQL 하위 쿼리의 결과를 뺍니다.
SELECT distinct
c.reporting as 'Agent_ID'
,count(a.pkey) as 'Total_Calls_Handled'
,a.MidnightStartDate as 'Call_Start_Time'
,datename(dw,a.midnightstartdate) as 'Week_day'
,a.[queue]
into #temp3
FROM t1 a
join t2 b
on a.FKAgent = b.fkagent
join t3 c
on a.agent = c.reporting
where a.agent in (
'132568'
,'116308'
,'132083'
,'113737'
)
and convert(date, midnightstartdate) BETWEEN '08/29/16' AND '08/30/19'
group by c.Reporting,a.MidnightStartDate,a.[queue]
SELECT distinct b.[Week_Day], a.[Queue],[Total ACD Calls], [Total ACD Calls Handled], count([total_calls_handled]) as 'Total ACD Calls Handledby Agent',
(select ((select [total acd calls handled] from #temp2) -
(select count([total_calls_handled]) from #temp3))) as 'OperatorsCalls'
INTO #Temp4
FROM #Temp2 a
JOIN #Temp3 b
ON a.[Queue] = b.[Queue]
GROUP BY [Total ACD Calls], [Total ACD Calls Handled], b.[Week_Day] , a.[Queue],[total_calls_handled]
# temp2 테이블에 여러 행의 결과가 포함되어있을 수 있으며 SINGLE 값이있는 단일 레코드 만 반환 될 수있는 컨텍스트에서 select를 사용하고 있습니다. –
예, 여러 행이 있습니다. 위의 코드는 기간이 1 일 동안 만 작동하는 경우 작동합니다. 그러나 나는 전체 주간의 차이를보고 싶다. 내가 할 수있는 방법이 있니? – Emarie