Posts that are tweeted and become hot and how much minutes apart

0

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 postid as [Post Link]
     , datediff(n, [52], [25]) [minutes hot - tweeted]
from (
  select *
  from (
    select postid
         , creationdate
         , posthistorytypeid
    from posthistory
    where posthistorytypeid in (25, 52) -- tweeted, hot
    ) src
    pivot
    (
      min(creationdate)
      for posthistorytypeid in ([25], [52])
    ) dst
  where [52] is not null and [25] is not null -- both events happened
) stats
order by datediff(n, [52], [25])

Enter Parameters

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