1
TRANSFORM Count(qryEAOCalls.CALLID) AS CountOfCALLID
SELECT qryEAOCalls.TAPSTAFFNAME, Count(qryEAOCalls.CALLID) AS [Total Calls]
FROM qryEAOCalls
WHERE qryEAOCalls.CALLDATE Between #1/1/1900# And Date()
GROUP BY qryEAOCalls.TAPSTAFFNAME
PIVOT qryEAOCalls.Status In ("Unassigned","Open","Closed","Follow-up Needed");

如何将其转换为等效的 T-SQL?

4

1 回答 1

1

您应该能够使用类似于以下内容的内容:

select TAPSTAFFNAME,
  Unassigned, Open, Closed, [Follow-up Needed],
  TotalCalls
from
(
  select e.TAPSTAFFNAME,
    e.CALLID,
    e.Status, 
    count(*) over(partition by e.TAPSTAFFNAME) TotalCalls
  from qryEAOCalls e
  where e.CALLDATE >= '1900-01-01'
    and e.CALLDATE <= getdate()
) src
pivot
(
  count(CALLID)
  for status in (Unassigned, Open, Closed, [Follow-up Needed])
) piv
于 2013-07-16T16:07:13.950 回答