SELECT * FROM (SELECT q.Id AS QID, a.Id AS AID, u.Reputat...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Beer, Wine & Spirits Meta Stack Exchange

Q&A for alcoholic beverage aficionados and those interested in beer, wine, or spirits

SELECT 
	*
FROM
	(SELECT 
		q.Id AS QID,
		a.Id AS AID,
		u.Reputation,
		u.upVotes,
		u.downVotes,
		a.CreationDate AS ACreationDate,
		MIN(a.CreationDate) AS AMinCreationDate
	FROM
		Posts q
		LEFT JOIN
		Posts a
		ON (q.Id = a.ParentId)
		LEFT JOIN
		Users u
		ON (a.OwnerUserId = u.Id)
	WHERE
		q.PostTypeId = 1 AND
		q.ClosedDate IS NULL AND
		(a.Id IS NULL OR q.OwnerUserId <> a.OwnerUserId) AND
		q.CreationDate >= '2017-10-08 00:00:00.0' AND
		q.CreationDate < '2017-10-15 00:00:00.0' 
	GROUP BY
		q.Id,
		a.Id,
		u.Reputation,
		u.upVotes,
		u.downVotes,
		a.CreationDate
	) qu
WHERE
	qu.ACreationDate = qu.AMinCreationDate
ORDER BY 
	qu.QID

Enter Parameters

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