SELECT CAST(FORMAT(CreationDate, 'yyyy-MM') as varchar(7)...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Ask Ubuntu

Q&A for Ubuntu users and developers

SELECT CAST(FORMAT(CreationDate, 'yyyy-MM') as varchar(7)) as yearmonth,
SUBSTRING(CAST(FORMAT(CreationDate, 'yyyy-MM') as varchar(7)), 1, 4) as years,
SUBSTRING(CAST(FORMAT(CreationDate, 'yyyy-MM') as varchar(7)), 6, 7) as months,
COUNT(*) as num_posts
FROM Posts
GROUP BY FORMAT(CreationDate, 'yyyy-MM')
ORDER BY FORMAT(CreationDate, 'yyyy-MM') ASC

Enter Parameters

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