WITH PostsDistribution AS ( SELECT year(CreationDate) AS ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Portuguese Language

Q&A for linguists, teachers and learners wanting to discuss the finer points of the Portuguese language

WITH PostsDistribution AS (
  SELECT year(CreationDate) AS year,
         month(CreationDate) AS month,
         count(Id) AS cnt
  FROM Posts
  WHERE PostTypeId = 1 OR PostTypeId = 2
  GROUP BY year(CreationDate), month(CreationDate)
)
SELECT s.year,
       s.month,
       round(100 - s.cur * 100.0 / s.prev, 0) as diff
FROM (
  SELECT year,
         month,
         cnt as cur,
         lag(cnt, 1) OVER (ORDER BY year, month) as prev
  FROM PostsDistribution
) s
WHERE s.prev > s.cur

Enter Parameters

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