我正在尝试为团队领导者创建一个基本的报告套件。他们将使用的最多是excel。对于excel文件,数据太大,因此数据存储在SQL数据库中,查询通过Excel文档运行。
我已经能够编写一个查询(下面)来引用过去30天的数据,但我需要创建一个报告,其中查询将引用2个单元格,其日期将决定结果中包含的日期,即日期从和日期到。团队负责人将在excel表中输入日期。
请问有人可以帮忙解决这个问题,因为我已经阅读了一些问题/答案并仍然在努力解决这个问题吗?
USE LeeM
SELECT
agent_hierarchy.agent_name AS "Agent",
AVG (log_in_time_seconds)/3600 AS "Dialler Hours",
AVG (Dialler_Calls) AS "Dialler Calls",
SUM (Preview_Seconds)/SUM(Dialler_Calls) AS "Preview per Call",
SUM (Talk_Seconds)/SUM(Dialler_Calls) AS "Talk per Call",
SUM (Wrap_Seconds)/SUM(Dialler_Calls) AS "Wrap per Call",
SUM (Idle_Seconds)/SUM(Dialler_Calls) AS "Idle per Call",
SUM (Not_Ready_Seconds)/SUM(Dialler_Calls) AS "Not Ready per Call"
FROM telephony
JOIN sm_date ON telephony.date = sm_date.D_Date
JOIN agent_hierarchy ON telephony.Agent_Lan_ID = agent_hierarchy.Agent_Lan_ID
WHERE sm_date.D_Date > DATEADD (day, -1, getdate())
GROUP BY agent_hierarchy.agent_name
ORDER BY agent_hierarchy.agent_name