SELECT SUM(CASE WHEN q.PostTypeId = 1 THEN q.Score ELSE 0...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Ask Ubuntu Meta

Q&A about the site for Ubuntu users and developers

-- Sum of Upvotes for Questions and Answers by Daniel Kaplan with Time Difference Less Than 10 Seconds
SELECT 
    SUM(CASE WHEN q.PostTypeId = 1 THEN q.Score ELSE 0 END) AS TotalQuestionUpvotes,
    SUM(CASE WHEN a.PostTypeId = 2 THEN a.Score ELSE 0 END) AS TotalAnswerUpvotes
FROM 
    Posts AS q
JOIN 
    Posts AS a ON q.Id = a.ParentId
WHERE 
    q.PostTypeId = 1  -- 1 indicates questions
    AND a.PostTypeId = 2  -- 2 indicates answers
    AND q.OwnerUserId = 61624  -- User ID for Daniel Kaplan
    AND a.OwnerUserId = 61624  -- User ID for Daniel Kaplan
    AND DATEDIFF(second, q.CreationDate, a.CreationDate) < 10  -- Time difference less than 10 seconds

Enter Parameters

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