Using the Stack Exchange Data Explorer I’m trying to figure out how many different users asked questions between 19 October 2012 and 9 November 2012. I’ve gotten my query to this:
SELECT Count(*)
FROM Posts
WHERE (CreationDate BETWEEN '2012-10-19' AND '2012-11-09') AND PostTypeId = 1
GROUP BY OwnerUserId
However, this returns 3,071 rows on Super User (I’m not going to try it on Stack Overflow). This seems way too high. Am I missing something?
If you just want to get a simple count of the distinct users, you can use the
DISTINCTkeyword like this:The distinct keyword will ensure that you only count each OwnerUserID once – the original question will just return the number of questions that each distinct user asked (which is fairly useless without additional context).
In effect, this query returns a count of the number of rows returned in the original query.