Count of posts by month

2

Please login or register to vote for this query.

(click on this box to dismiss)

Simple count of posts by month

Emacs

Q&A for those using, extending or developing Emacs

-- Count of posts by month
-- Simple count of posts by month
select datepart(year, p.creationdate) as year,
datepart(month, p.creationdate) as month,
cast(datepart(year, p.creationdate) as varchar(max)) +'-'+
   case when len(datepart(month, p.creationdate))=1  then '0' else '' end +
   cast(datepart(month, p.creationdate) as varchar(max)) as yearmonth,
count(*) as postcount
from posts p
group by datepart(year, p.creationdate),
datepart(month, p.creationdate)
order by datepart(year, p.creationdate),
datepart(month, p.creationdate)

Enter Parameters

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