compare post volume in two periods

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

with period1 as (select count(*) as PostCount
               from PostsWithDeleted
               where CreationDate >= '##start1##'
               and CreationDate < '##end1##'
               ),
    period2 as (select count(*) as PostCount
               from PostsWithDeleted
               where CreationDate >= '##start2##'
               and CreationDate < '##end2##'
               )
select period1.PostCount as range1, 
       period2.PostCount as range2,
       round(100*(period2.PostCount/(period1.PostCount + 0.1) - 1), 1) as percentChange 
from period1, period2

Enter Parameters

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