Daily Activity Posts Comments Users

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT *
FROM

(
SELECT   CAST (CreationDate AS Date)Date_Posted
	,SUM(CASE WHEN PostTypeID=1 THEN 1 ELSE 0 END) As Questions
    ,SUM(CASE WHEN PostTypeID=2 THEN 1 ELSE 0 END) As Answers
FROM Posts
 WHERE YEAR(CreationDate)=2014 and DeletionDate is null
 GROUP BY CAST(CreationDate as Date)
 )a

 FULL OUTER JOIN
 
 (
 SELECT CAST (CreationDate AS Date)Date_Joined
     ,COUNT(*) AS Users
 FROM Users
  WHERE YEAR(CreationDate)=2014
 GROUP BY CAST(CreationDate as Date)
 )b
 
 on a.Date_Posted = b.Date_Joined
 
FULL OUTER JOIN
(
 SELECT CAST (CreationDate AS Date)Date_Commented
     ,COUNT(*) AS Comments
 FROM Comments
  WHERE YEAR(CreationDate)=2014
 GROUP BY CAST(CreationDate as Date)
 )c
 
 ON c.Date_Commented = a.Date_Posted

Enter Parameters

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