我有 2 个查询我想在不使用联合的情况下合并到 1 个结果集中。
查询 1
select datepart(yy,dateclosed)as 'Year',
datepart(mm,dateclosed) as 'Month',
count(*)as 'Total'
from bug
where projectid = 44
and ifclosed = 1
and isnull(createdbyperson,1) <> '-1111111110'
and datepart(yy,dateclosed) > '2000'
group by datepart(yy,dateclosed), datepart(mm,dateclosed)
order by 1,2
查询 2
select datepart(yy,dateclosed)as 'Year',
datepart(mm,dateclosed) as 'Month',
count(*)as 'SameDay'
from bug
where projectid = 44
and ifclosed = 1
and isnull(createdbyperson,1) <> '-1111111110'
and datepart(yy,dateclosed) > '2000'
and CONVERT(VARCHAR(10), dateclosed, 101) = CONVERT(VARCHAR(10), datecreated, 101)
group by datepart(yy,dateclosed),datepart(mm,dateclosed)
order by 1,2
我希望它返回值为 Year、Month、SameDay、Total。我如何实现这一目标?联盟没有做我想做的事。我必须进行连接和表别名吗?子查询?
提前致谢。