Select rows where column 1 value is the same but column 2 value is different in PostgreSQL
<p>I'm working on PostgreSQL on a table with this structure :  </p>

<pre><code>________________
|project|person|
|_______|______|
|1      |P1    |
|1      |P2    |
|2      |P3    |
|2      |P3    |
|3      |P4    |
|_______|______|
</code></pre>

<p>I would like to write a SQL query to select ONLY the rows where one project has more than one person. In other words, I would like to select all the rows where the project is the same but the person is different, excluding the other rows. In my example it would return only the two first rows :</p>

<pre><code>________________
|project|person|
|_______|______|
|1      |P1    |
|1      |P2    |
|_______|______|
</code></pre>

<p>I can not wrap my head arround this. Is saw <a href="https://stackoverflow.com/questions/16273427/how-to-select-rows-where-a-combination-of-2-columns-is-the-same">this question</a> which is basically the opposite but I don't see how to make it work for me.</p>

<p>I tried to fiddle with COUNT or HAVING for a long time but I can not grasp the logic of how I should build this query. For example I tried :</p>

<pre><code>SELECT t.person, t.project
FROM table t
GROUP BY r.ide_proj, r.ide_pers
HAVING COUNT(t.person) &gt; 1
</code></pre>

<p>but this gives me strange results, including rows whre one projects only has one person, or vice-versa.</p>

<p>Can somebody help me with this little problem ?</p>

<p>Many thanks !</p>