ユニオンを使用せずに 1 つの結果セットにマージしたい 2 つのクエリがあります。
クエリ 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
年、月、同じ日、合計として値を返すようにしたいと思います。どうすればこれを達成できますか? ユニオンは私がやりたいことをしません。結合とテーブル エイリアスを実行する必要がありますか? サブクエリ?
前もって感謝します。