SELECT COUNT(*) FROM ( SELECT p.Id FROM Posts p JOIN Vot...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Motor Vehicle Maintenance and Repair Meta

Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles

-- Enter Query Title
-- Enter Query Description

SELECT
    COUNT(*)
FROM
( SELECT
    p.Id 
FROM
    Posts p
JOIN
    Votes v
ON  p.Id = v.PostId
WHERE
    p.PostTypeId = 1
AND p.Score = 0
GROUP BY
    p.Id
HAVING
    COUNT(*) = 2
) AS candidates   
JOIN
    Votes dv
ON  dv.PostId = candidates.Id
AND dv.VoteTypeId = 3
WHERE
    EXISTS (
    SELECT 1
    FROM Votes uv
    WHERE uv.PostId = dv.PostId
    AND   uv.VoteTypeId = 2
    AND   uv.CreationDate < dv.CreationDate
    )
    

Enter Parameters

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