title: Cannot update the view or function 'cte' because it contains aggregates, or a DISTINCT or GROUP BY clause, or PIVOT or UNPIVOT operator
body: <p>I want to delete using Having by .</p>
  
  <p>So i try to execute the following statement :</p>
  
  <pre><code>;WITH cte As
  (
   select  emp_num, [from_date],[to_date],[ req_ser], [ req_year] 
  from empmission
  group by emp_num, [from_date],[to_date],[ req_ser], [ req_year]
  having count(*) &gt;2
  )
  
  DELETE 
  FROM    cte
  </code></pre>
  
  <p>but i get the following exception :</p>
  
  <blockquote>
    <p>Cannot update the view or function 'cte' because it contains
    aggregates, or a DISTINCT or GROUP BY clause, or PIVOT or UNPIVOT
    operator.</p>
  </blockquote>