Who's asking/answering the most questions on U.S. holidays?! (And why? ... just kidding, we know why...)
Q&A for meta-discussion of the Stack Exchange family of Q&A websites
-- Holiday Work Horse -- Who's asking/answering the most questions on U.S. holidays?! (And why? ... just kidding, we know why...) --DECLARE @year int = ##Year## SELECT u.DisplayName as 'User Name' ,count(p.Id) as 'Number of Questions/Answers' ,(u.Reputation/(count(p.Id))) as 'Reputation' FROM users u INNER JOIN posts p on p.OwnerUserId = u.id WHERE 1=1 AND (p.PostTypeId IN (1,2)) /* Questions and Answers */ AND p.OwnerUserId IS NOT NULL /* Registered Users */ AND u.Reputation > 250 /* Reputation min. */ -- AND u.DisplayName = 'iight' /* not me... */ -- AND year(p.CreationDate) = @year /* Year input */ AND ( (Month(p.CreationDate) = 12 AND Day(p.CreationDate) = 25) /* Xmas */ OR (Month(p.CreationDate) = 7 AND Day(p.CreationDate) = 4) /* July 4 */ ) GROUP BY u.DisplayName,u.Reputation HAVING count(p.Id)> 0 ORDER BY 'Number of Questions/Answers' DESC