title: sql delete based on group by
body: <p>I have following query:</p>
  
  <pre><code>select user_id, trajectory_id, count(trajectory_id) from point group by user_id, trajectory_id
  </code></pre>
  
  <p>It returns following result:
  <img src="https://i.stack.imgur.com/evZXY.png" alt="enter image description here"></p>
  
  <p>And I want to delete all records from <code>point</code> table where <code>count</code> in produced table is &lt; 5.</p>
  
  <p>Right now I have following query, but it is not compiling. What is wrong with it and how can I fix it?</p>
  
  <pre><code>delete 
  from point
  where count(trajectory_id) &lt; 5
  GROUP BY user_id, trajectory_id
  </code></pre>
  
  <p>I am using Postgres.</p>