For each month, when compared with the previous month, the number of posts (questions and answers) has decreased, to withdraw the year, month and percentage reduction. For example, last month there were 200 posts, and in this - 100. Reduction by 50%.

http://data.stackexchange.com/stackoverflow/query/new

Help me please. Thank you in advance!

  • And for what purpose are you interested? ;) - Mike

1 answer 1

select mm,cnt as curr,prev,round(100-cnt*100.00/prev,2) prc from ( select mm,cnt,lag(cnt) over (order by mm) prev from ( select year(creationDate)*100+month(creationDate) as mm, count(1) as cnt from posts where PostTypeId between 1 and 2 group by year(creationDate)*100+month(creationDate) ) A ) A where cnt < prev order by mm 
  • Thank you so much!!! - Name