 <p>This uses <code>MAX</code> and <code>MIN</code> to see to that all values are the same; one needs to add a <code>+ 0</code> to each bit to make it available to normal numeric aggregate functions (like <code>MIN</code>/<code>MAX</code>/<code>SUM</code>/...)</p> <pre><code>SELECT ProjectId, EmployeeId FROM Temp GROUP BY ProjectId, EmployeeId HAVING MAX(IsWarning + 0) = 0 AND MAX(IsExpired + 0) = 0 AND MIN(IsIncomplete + 0) = 1 </code></pre> <p><a href="http://sqlfiddle.com/#!6/27b07/2" rel="nofollow">An SQLfiddle for testing</a>.</p>