SELECT cl.day, cl.month, cl.year, Outgoing, Incoming from...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Super User

Q&A for computer enthusiasts and power users

SELECT cl.day, cl.month, cl.year, Outgoing, Incoming
from (select COUNT(ph.PostId) as [Outgoing]
     , day(ph.creationdate) as Day
     , month(ph.creationdate) as Month
     , year(ph.creationdate) as year
from posthistory ph
inner join posts p on p.id = ph.postid
where posthistorytypeid = 35 -- migrated away
and p.posttypeid = 1 -- question
and month(ph.creationdate) = Month(getdate())
and year(ph.creationdate) = year(getdate())
group by year(ph.creationdate), month(ph.creationdate), day(ph.creationdate)
) as cl
full outer join 
(
select COUNT(ph.PostId) as [Incoming]
     , day(ph.creationdate) as Day
     , month(ph.creationdate) as Month
     , year(ph.creationdate) as year
from posthistory ph
inner join posts p on p.id = ph.postid
where posthistorytypeid = 36 -- migrated here
and p.posttypeid = 1 -- question
and month(ph.creationdate) = Month(getdate())
and year(ph.creationdate) = year(getdate())
group by year(ph.creationdate), month(ph.creationdate), day(ph.creationdate)
) as del
on cl.day = del.day and cl.month = del.month and cl.year = del.year
order by day desc

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results