N
Nero
HI there....
I have two questions based on the below SQL statement
1. the query takes too long to run, is the query too complex and if so how
do I make it better so that it responds faster?
2. The first part of the WHERE statement matches the month in one table to
the month in another table, i need this to match the month and the year, how
do I do this?
note: i used the query wizard to start the query and then aded in the
formulas i needed.
SQL Statement
SELECT DISTINCTROW Format$(ActivityTbl.Date,'mmmm yyyy') AS [Date], [Agent_
Details].Region, Sum(DailyScheduledTime.ScheduledTime) AS TotalScheduledTime,
Sum(ActivityTbl.ActualCalls) AS ActualCalls, Avg(ActivityTbl.ActualAht) AS
AvgAht, Max(ActivityTbl.ActualAht) AS MaxAht, Avg(targets.AHTTarget) AS
AHTTarget, TotalScheduledTime/AHTTarget AS TargetCalls,
TargetCalls/ActualCalls*100 AS productivity, Avg(targets.ProdBudget) AS
ProdBudget, Productivity/prodBudget*100 AS ProdOutcome, AHTTArget/MaxAht*100
AS Efficiency, Avg(targets.AHTBudget) AS EfficiencyBudget,
Efficiency/EfficiencyBudget*100 AS EfficiencyOutcome, [Agent_
Details].JobTitle
FROM targets, ([Agent_ Details] INNER JOIN DailyScheduledTime ON [Agent_
Details].AgentId = DailyScheduledTime.AgentId) INNER JOIN ActivityTbl ON
[Agent_ Details].AgentId = ActivityTbl.AgentId
WHERE
(((DatePart("m",[ACtivityTbl].[date]))=(DatePart("m",[targets].[date])))) AND
([Agent_ Details].JobTitle)=(targets.serviceArea)
GROUP BY Format$(ActivityTbl.Date,'mmmm yyyy'), [Agent_ Details].Region,
Year(ActivityTbl.Date)*12+DatePart('m',ActivityTbl.Date)-1, [Agent_
Details].JobTitle;
I have two questions based on the below SQL statement
1. the query takes too long to run, is the query too complex and if so how
do I make it better so that it responds faster?
2. The first part of the WHERE statement matches the month in one table to
the month in another table, i need this to match the month and the year, how
do I do this?
note: i used the query wizard to start the query and then aded in the
formulas i needed.
SQL Statement
SELECT DISTINCTROW Format$(ActivityTbl.Date,'mmmm yyyy') AS [Date], [Agent_
Details].Region, Sum(DailyScheduledTime.ScheduledTime) AS TotalScheduledTime,
Sum(ActivityTbl.ActualCalls) AS ActualCalls, Avg(ActivityTbl.ActualAht) AS
AvgAht, Max(ActivityTbl.ActualAht) AS MaxAht, Avg(targets.AHTTarget) AS
AHTTarget, TotalScheduledTime/AHTTarget AS TargetCalls,
TargetCalls/ActualCalls*100 AS productivity, Avg(targets.ProdBudget) AS
ProdBudget, Productivity/prodBudget*100 AS ProdOutcome, AHTTArget/MaxAht*100
AS Efficiency, Avg(targets.AHTBudget) AS EfficiencyBudget,
Efficiency/EfficiencyBudget*100 AS EfficiencyOutcome, [Agent_
Details].JobTitle
FROM targets, ([Agent_ Details] INNER JOIN DailyScheduledTime ON [Agent_
Details].AgentId = DailyScheduledTime.AgentId) INNER JOIN ActivityTbl ON
[Agent_ Details].AgentId = ActivityTbl.AgentId
WHERE
(((DatePart("m",[ACtivityTbl].[date]))=(DatePart("m",[targets].[date])))) AND
([Agent_ Details].JobTitle)=(targets.serviceArea)
GROUP BY Format$(ActivityTbl.Date,'mmmm yyyy'), [Agent_ Details].Region,
Year(ActivityTbl.Date)*12+DatePart('m',ActivityTbl.Date)-1, [Agent_
Details].JobTitle;