top 10 users who made the most comments and posts over the past 5 years

0

Please login or register to vote for this query.

(click on this box to dismiss)

Musical Practice and Performance Meta

Q&A about the site for musicians, students, and enthusiasts

SELECT TOP 10 u.id, COUNT(*) AS activity
FROM Users u
LEFT JOIN (
SELECT p.OwnerUserId AS user_id
FROM posts p
WHERE p.CreationDate >= DATEADD(YEAR, -5, GETDATE())
    
UNION ALL
    
SELECT c.UserId AS user_id
FROM Comments c
WHERE c.CreationDate >= DATEADD(YEAR, -5, GETDATE())
) AS user_activity ON u.id = user_activity.user_id
GROUP BY u.id
ORDER BY COUNT(*) DESC

Enter Parameters

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