Votes that are after one week aggregated weekly

1

Please login or register to vote for this query.

(click on this box to dismiss)

Statistical Analysis

Q&A for statisticians, data analysts, data miners and data visualization experts

SELECT
COUNT(*) AS Total_Votes,
datepart(year, Posts.CreationDate) AS YEAR_POST,
datepart(week, Posts.CreationDate) AS WEEK_POST,
SUM(CASE WHEN (DATEDIFF(day,Posts.CreationDate,Votes.CreationDate) > 7) THEN 1 ELSE 0 END) AS AFTER_WEEK
FROM Votes
    INNER JOIN Posts ON Votes.PostId = Posts.Id
WHERE Votes.VoteTypeId = 2 OR Votes.VoteTypeId = 3
GROUP BY
    datepart(year, Posts.CreationDate), datepart(week, Posts.CreationDate)
ORDER BY YEAR_POST,WEEK_POST

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached