select y_r, mm,cnt as curr,prev,round(100-cnt*100.00/prev...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Woodworking

Q&A for professional and amateur woodworkers

select y_r, mm,cnt as curr,prev,round(100-cnt*100.00/prev,2) as prc
  from (
   select y_r, mm,cnt,lag(cnt) over (order by mm) as prev
     from (
      select year(creationDate) as y_r,
             month(creationDate) as mm,
             count(1) as cnt
        from posts
       where PostTypeId between 1 and 2
       group by year(creationDate), month(creationDate)
   ) A
  ) A
 where cnt < prev
 order by y_r, mm

Enter Parameters

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