I've got 2 queries I'd like to merge into 1 result set without using union.
Query 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
Query 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
Id like it to return the values as Year,Month,SameDay,Total. How do I achieve this? Union doesn't do what I want it to do. Do I have to do a join and a table alias? Subquery?
Thanks in advance.