average first score if body does NOT contains "downvote"

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT sum(p.Score), count(p.Score), (sum(p.Score)*1.0)/count(p.Score) as ave
FROM POSTS p
LEFT JOIN USERS u
ON p.OwnerUserId = u.Id
LEFT JOIN (
    SELECT u.Id as u_id, min(p.ID) as min_pid
    FROM POSTS p
    LEFT JOIN USERS u
    ON p.OwnerUserId = u.Id
    GROUP BY u.Id) as mp
ON mp.u_id = u.Id AND mp.min_pid = p.Id
WHERE p.PostTypeId = 1 AND p.Body LIKE '%downvote%' AND p.Id > ##cutoff:int##

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results