How to find out the count of one column in multiple group by using MySQL?
<p>I have a table called <code>options</code> with the following data:</p>

<pre><code>id|content|index| question_id
----------------------------
1 | yes   |  1  | 123
2 | no    |  2  | 123
3 | maybe |  1  | 123
4 | yeah  |  2  | 124
5 | yep   |  1  | 124
6 | nope  |  1  | 125
7 | no    |  2  | 125
8 | yessir|  1  | 125
</code></pre>

<p>Each option is mapped to an MCQ question on the question_id. There cannot be duplicated indexes for a question. 
I want to <strong>find out the number of options with duplicate indexes against the same question_id</strong></p>

<p>Here's how I am trying to do it:</p>

<pre><code>SELECT 
  count(index) as c, 
  question_id 
from options 
group by question_id, index having c &gt; 1
</code></pre>

<p>However, I don't seem to get the result I am looking for. </p>

<p>I want to get the following rows called out:</p>

<pre><code>id | content | index | question_id
-----------------------------------
3  | maybe   | 1     | 123
8  | yessir  | 1     | 125
</code></pre>

<p>Also, the following result set will help as well:</p>

<pre><code>question_id | duplicates
-------------------------
123         | 2
125         | 2
</code></pre>