SELECT U.Id AS UserId, DATEDIFF(DAY, U.CreationDate, GETD...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Music Fans Meta

Q&A about the site for music historians, critics, and fans

SELECT 
    U.Id AS UserId,
    DATEDIFF(DAY, U.CreationDate, GETDATE()) AS AccountAgeDays,
    U.UpVotes,
    U.DownVotes,
    U.Views,
    ISNULL(AVG(P.Score), 0) AS AvgPostScore,
    COUNT(P.Id) AS TotalPosts
FROM 
    Users U
LEFT JOIN 
    Posts P 
ON 
    U.Id = P.OwnerUserId
GROUP BY 
    U.Id, U.CreationDate, U.UpVotes, U.DownVotes, U.Views
HAVING 
    COUNT(P.Id) > 5 -- Optional: Filter active users
ORDER BY 
    UserId
OFFSET 0 ROWS FETCH NEXT 500 ROWS ONLY; -- Fetch 500 users

Enter Parameters

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