select OwnerUserId, year, count(month) as active_months f...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Network Engineering

Q&A for network engineers

select 
OwnerUserId,
year,
count(month) as active_months
from
 ( select 
   OwnerUserId,
   DATENAME(year, CreationDate) as year,
   DATENAME(month, CreationDate) as month
   from Posts
   where DATENAME(year, CreationDate) >= 2010 AND DATENAME(year, CreationDate) <= 2020 
   group by 
      OwnerUserId 
     ,DATENAME(year, CreationDate)
     ,DATENAME(month, CreationDate)
 ) as dt
 group by OwnerUserId, year
 order by OwnerUserId

Enter Parameters

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