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)

Mathematics

Q&A for people studying math at any level and professionals in related fields

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 meta site
loading Hold tight while we fetch your results