 <pre><code>select * from log_metrics a inner join (select session_id from log_metrics group by session_id having count(*) &gt; 10) b on a.session_id = b.session_id </code></pre> <p>Here's a SQL fiddle: <a href="http://sqlfiddle.com/#!2/7bed6/3" rel="nofollow">http://sqlfiddle.com/#!2/7bed6/3</a></p>