Percentage of spam posts that lasted at least N minutes (per week)

1

Please login or register to vote for this query.

(click on this box to dismiss)

Genealogy and Family History Meta

Q&A about the site for expert genealogists and people interested in genealogy or family history

---see also: Number of spam posts that lasted at least ten minutes (per week)
--- https://data.stackexchange.com/mathoverflow/query/1768124/number-of-spam-posts-that-lasted-at-least-ten-minutes-per-week#graph

;  with spam_cte as
(SELECT DISTINCT 
  p.Id AS pid,
  DATEDIFF(minute, p.CreationDate, p.DeletionDate) AS Minutes,
  p.CreationDate AS cre,
  p.DeletionDate AS del
FROM PostsWithDeleted p INNER JOIN Votes v ON v.PostId=p.Id
WHERE v.VoteTypeId=##votetype?12## 
AND (p.DeletionDate IS NOT NULL))
, counts_cte as
(SELECT 
  DATEADD(dd, -(DATEPART(dw, cre)-1), CAST(cre AS Date)) AS WeekStart,
  COUNT(pid) AS CountAll,
  SUM(case when (minutes>=##min?10##) then 1 else 0 end) AS CountLong
FROM spam_cte
GROUP BY DATEADD(dd, -(DATEPART(dw, cre)-1), CAST(cre AS Date))
)

SELECT
  WeekStart,
  ROUND(CountLong*100.0/CountAll,2) AS percentage
FROM counts_cte
ORDER BY WeekStart

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results