SQL Query for counting identifiers with exactly 91 duplicates

I have a mySQL database for survey responses. Each of them has a user identifier, a question identifier, and an actual answer. Now I'm trying to write a report that tells me how many people actually completed the survey, and did not stop halfway. Therefore, I am trying to figure out how to write a query that will read all user identifiers that are duplicated exactly 91 times.

Be careful, this is my first stack question.

+3
source share
3 answers

You need to group with the score (*) = 91

select userId from myTable group by userId having count(*) = 91

http://dev.mysql.com/doc/refman/5.0/en/group-by-hidden-columns.html

+2
source

I have no data to verify this, but this may help:

SELECT COUNT(*) AS userCount, userId
FROM tbl
GROUP BY userId
HAVING userCount = 91
+1

, ID :

SELECT COUNT(*) FROM SurveyResponses WHERE QuestionId= [last_question_id]
0

All Articles