我有两个疑问。第一个返回一个日期范围内在同一天创建和关闭的事件数:
SELECT Count(*) [# Incidents Closed First Day], CONVERT(VARCHAR, Rn_Create_Date, 101) [Date]
FROM dbo.Support_Incident
WHERE --created and closed on same day. i.e closed first day
CONVERT(VARCHAR, Rn_Create_Date, 101) = CONVERT(VARCHAR, Date_Closed, 101) AND
rn_Create_Date > CONVERT(DATETIME, '2013-07-01 00:00:00', 102) AND
rn_Create_Date < CONVERT(DATETIME, '2013-07-30 00:00:00', 102)
GROUP By CONVERT(VARCHAR, Rn_Create_Date, 101)
我有另一个查询,它返回按日期分组的同一日期范围内创建的事件总数:
SELECT Count(*) [Total Incidents Created], CONVERT(VARCHAR, Rn_Create_Date, 101) [Date]
FROM dbo.Support_Incident
WHERE
rn_Create_Date > CONVERT(DATETIME, '2013-07-01 00:00:00', 102)
AND rn_Create_Date < CONVERT(DATETIME, '2013-07-30 00:00:00', 102)
GROUP By CONVERT(VARCHAR, Rn_Create_Date, 101)
我真正想要的是一个组合这两个查询的单个结果集,以便每一行显示一天内创建的事件数以及当天创建和关闭的事件数。
有没有办法创建一个合并这两个查询以提供单个结果集的查询?