Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Query to count IDs with exactly 91 duplicates

Tags:

sql

mysql

I've got a mySQL database of survey responses. Each one has a userID, a questionID and the actual answer. Now I'm trying to write a report that will tell me how many people actually completed the survey as opposed to stopped halfway through. So I'm trying to figure out how to write a query that will count all of the userIDs that are duplicated exactly 91 times.

Be gentle, this is my first stackoverflow question.

like image 707
Epiktetus Avatar asked Nov 30 '25 14:11

Epiktetus


1 Answers

You have to group by having count(*) = 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

like image 87
Avitus Avatar answered Dec 03 '25 05:12

Avitus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!