select *, count(*) from( select CAST( cast(DATEPART(YYYY...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

select *, count(*) from(

  select CAST(
        cast(DATEPART(YYYY, pl.CreationDate) as varchar) + '-' + cast(DATEPART(MM, pl.CreationDate) as varchar) + '-01'
        as datetime) as Mon
  FROM PostLinks pl
  JOIN (select Id, CreationDate from Posts) as tp ON tp.Id = pl.PostId
  JOIN (select Id, CreationDate from Posts) as mp ON mp.Id = pl.RelatedPostId
  WHERE pl.LinkTypeId = 3
  AND tp.CreationDate < mp.CreationDate
) as X
group by Mon
order by Mon ASC

Enter Parameters

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