with qa as ( SELECT p.OwnerUserId, MONTH(p.CreationDate) ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Network Engineering

Q&A for network engineers

with qa as (
  SELECT
  p.OwnerUserId,
  MONTH(p.CreationDate) AS Month,
  YEAR(p.CreationDate) AS Year,
  SUM(CASE WHEN p.PostTypeId = 2 THEN 1 ELSE 0 END) As Answer,
  SUM(CASE WHEN p.PostTypeId = 1 THEN 1 ELSE 0 END) As Question,
  SUM(p.ViewCount) as ViewCount,
  SUM(p.CommentCount) as ReceivedComments, 
  SUM(p.AnswerCount) as AnswerCountReceived
  FROM Posts as p
  WHERE p.PostTypeId In (1,2) AND YEAR(p.CreationDate) >= 2010 AND YEAR(p.CreationDate) <= 2020 AND p.OwnerUserId in ('16007','182668','134554','223992','9204','15416','3501','65863','139985','179910','252228','225074','7432','3043','143305','218196','22656','87189','69545','107090','50617','2988','65387','149392','33518','23354','6309','13508','1338','115145','18771','14860','476','131930','16406','15168','146325','89817','140750','13302','1968','19068')
  GROUP BY p.OwnerUserId, YEAR(p.CreationDate), MONTH(p.CreationDate)
)
SELECT 
    u.Id as UserId,
    p.Year,
    p.Month,
    p.Answer,
    p.Question,
    p.ViewCount,
    p.ReceivedComments,
    p.AnswerCountReceived,
    datediff(MONTH,u.CreationDate,DATEFROMPARTS(p.Year, p.Month, 1)) as [Tenure(in Month)]
FROM Users as u
inner join qa as p on u.Id = p.owneruserid
WHERE u.Id > 0
ORDER BY u.Id, p.Year

Enter Parameters

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