PTIJ velocity/quality correlation

0

Please login or register to vote for this query.

(click on this box to dismiss)

Mi Yodeya

Q&A for those who base their lives on Jewish law and tradition and anyone interested in learning more

select
  buckets.name,
  buckets.low,
  buckets.high,
  count(scores_and_hours.score) as N,
  avg(scores_and_hours.score*1.0) as avg_score
from
(
  select
    p_ptij.score as score,
    case when max(p_ptij_prev.creationdate) is null then 99999999 -- Never before
      else datediff(hh, max(p_ptij_prev.creationdate), p_ptij.creationdate) end 
      as hours_since_last
  from 
    (select p.creationdate, p.owneruserid, p.score
     from posts p
     inner join posttags pt on p.id=pt.postid
     inner join tags t on pt.tagid=t.id
       and t.tagname='purim-torah-in-jest'
     where p.posttypeid = 1 -- q
     ) p_ptij
  left outer join
    (select p.creationdate, p.owneruserid
     from posts p
     inner join posttags pt on p.id=pt.postid
     inner join tags t on pt.tagid=t.id
       and t.tagname='purim-torah-in-jest'
     where p.posttypeid = 1 -- q
     ) p_ptij_prev
  on p_ptij_prev.owneruserid = p_ptij.owneruserid
    and p_ptij_prev.creationdate < p_ptij.creationdate
  group by p_ptij.score, p_ptij.creationdate
) scores_and_hours
inner join
(
  select * from 
  ( 
   values ('same hour', 0, 1),
   ('second hour', 1, 2),
   ('same day', 2, 24),
   ('second day', 24, 48),
         ('same season', 48, 999), -- two weeks = 336 hours
         ('first of season', 999, 99999), -- ten years = 87600 hours
         ('first ever', 99999, 999999999)
  ) as buckets (name, low, high)
  ) buckets
on buckets.low <= scores_and_hours.hours_since_last
and buckets.high > scores_and_hours.hours_since_last
group by  buckets.name, buckets.low, buckets.high
order by buckets.low asc

Enter Parameters

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