SQL Server 2000 を使用しているため、CTE を使用できません
DECLARE @reportdate AS DATETIME
SET @reportdate='08/26/2013'
最初のクエリ
SELECT SUM(NENTEREDACD) AS calls,
DINTERVALSTART
FROM dbo.QUEUESTATS
WHERE ( DINTERVALSTART > @reportdate + ' 00:00:00.000' )
AND ( DINTERVALSTART < DATEADD(d, 1, @reportdate) + ' 00:00:00.000' )
GROUP BY DINTERVALSTART
ORDER BY DINTERVALSTART
2 番目のクエリ
SELECT count(cname) AS AvaiAgents,
dintervalstart AS startdatetime
FROM (SELECT dintervalstart,
cname
FROM [dbo].[AGENTSTATS]
GROUP BY dintervalstart,
cname
HAVING ( DINTERVALSTART > @reportdate + ' 00:00:00.000' )
AND ( DINTERVALSTART < DATEADD(d, 1, @reportdate) + ' 00:00:00.000' )) T
GROUP BY T.dintervalstart
3 番目のクエリ
SELECT count(cname) AS ActiveAgents,
dintervalstart AS startdatetime
FROM (SELECT dintervalstart,
cname
FROM [dbo].[AGENTSTATS1]
GROUP BY dintervalstart,
cname
HAVING ( DINTERVALSTART > @reportdate + ' 00:00:00.000' )
AND ( DINTERVALSTART < DATEADD(d, 1, @reportdate) + ' 00:00:00.000' )) T
GROUP BY T.dintervalstart
最初のクエリからレコードのみを取得したいので、3 つの異なるクエリから 3 つの列を取得する必要があります。よくあるのはタイムスタンプ
I inetval Calls Avaiagents Active agents
08/26/2012 20 22 23