select t2.d_year, t2.d_month, Round(100.0 * t2.diff / t2....

0

Please login or register to vote for this query.

(click on this box to dismiss)

Computational Science

Q&A for scientists using computers to solve scientific problems

select t2.d_year, t2.d_month, Round(100.0 * t2.diff / t2.prev_month,2) as Percentage

from


(select t1.d_year, t1.d_month, count(t1.id) as d_count,
LAG(count(t1.id)) OVER (ORDER BY t1.d_year, t1.d_month) AS prev_month, 
count(t1.id) - (LAG(count(t1.id)) OVER (ORDER BY t1.d_year, t1.d_month)) as diff
from
(

select id, YEAR(CreationDate) as d_year, MONTH(CreationDate) as d_month
from comments
) t1
group by t1.d_month, t1.d_year
) t2
where Round(100.0 * t2.diff / t2.prev_month,2) < 0
order by t2.d_year, t2.d_month

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results