SELECT TOP 10 p.Id as question, d.Id as answer,d.OwnerUse...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Software Engineering

Q&A for expert programmers interested in professional discussions on software development

SELECT TOP 10 p.Id as question, d.Id as answer,d.OwnerUserId as answererId, d.Reputation as answerer_reputation, vt.UpVotes, vt.DownVotes, d.CreationDate
FROM Posts as p
JOIN (
 SELECT c.Id, c.ParentId, c.CreationDate, c.OwnerUserId, u.Reputation 
 From Posts AS c 
 JOIN Users AS u ON c.OwnerUserId = u.AccountId
 WHERE c.PostTypeId=2 AND c.CreationDate BETWEEN '2015-07-31' AND '2017-12-31'
     ) AS d ON d.ParentId = p.Id
JOIN (
 SELECT v.PostId,
   SUM(CASE WHEN v.VoteTypeId = 2 THEN 1 ELSE 0 END) AS UpVotes,
   SUM(CASE WHEN v.VoteTypeId = 3 THEN 1 ELSE 0 END) AS DownVotes
 FROM Votes AS v
 GROUP BY v.PostId
) AS vt ON d.Id = vt.PostId
WHERE p.CreationDate BETWEEN '2015-07-31' AND '2017-12-31' 
ORDER BY p.CreationDate ASC, d.CreationDate ASC;

Enter Parameters

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