Q&A about the site for practitioners of the art and science of signal, image and video processing
WITH lag_tags AS ( SELECT *, LAG(total) OVER(PARTITION BY sub_q.Class ORDER BY Years ASC) AS last_month_revenue FROM( SELECT YEAR(Comments.CreationDate) AS Years, Badges.Class, COUNT(*) AS total FROM COMMENTS LEFT JOIN Users ON Comments.UserId = Users.Id JOIN Badges ON Comments.UserId = Badges.UserId WHERE YEAR(Comments.CreationDate)>= 2019 GROUP BY Badges.Class, YEAR(Comments.CreationDate)) AS sub_q ) SELECT *, ((last_month_revenue - total) / total) AS growth FROM lag_tags WHERE last_month_revenue IS NOT NULL ORDER BY (last_month_revenue - total) / total