title: Delete duplicates from the table pl/sql oracle
body: <p>I have a table that contains data and fields:</p>
  <pre><code>contact_id | call_siebel | start_time | operator_text | client_text | client_id | phone_num
  </code></pre>
  <p>I found duplicates:</p>
  <pre><code>SELECT operator_text, client_text, client_id
  FROM TABLE
  GROUP BY operator_text, client_text, client_id
  HAVING COUNT(*) &gt; 1;
  </code></pre>
  <p>For example, there are 4 identical data, two of which have the same client_id value
  (correct) and the other two have client_id = '-1'. And I need to leave
  only one option out of four, whose client_id is filled in correctly.</p>
  <p>I wanted to create a test table in which I will enter data with a unique value
  client_id from all duplicates that exist, remove duplicates from the main table
  data on client_id and in the end just insert from the test table into the main one.</p>
  <p>How would it be more correct to insert data from the main table into the test one with a unique
  client_id from all duplicates? In my version, I incorrectly implemented GROUP BY:</p>
  <pre><code>INSERT /*+ append enable_parallel_dml parallel(16)*/
  INTO table_test
  SELECT
   DISTINCT 
   t.contact_id, 
   t.call_siebel, 
   t.start_time, 
   t.operator_text, 
   t.client_text, 
   t.client_id, 
   t.phone_num
  FROM table t
  WHERE t.client_id != '-1'
  GROUP BY t.operator_text, t.client_text, t.client_id
  HAVING COUNT(t.client_id) &gt; 1;
  </code></pre>
  <p>After this I could easily finish my job using:</p>
  <pre><code>DELETE table
  WHERE client_id
  IN (SELECT t.client_id
  FROM table_test t);
  
  
  INSERT 
  INTO table
  SELECT *
  FROM table_test;
  </code></pre>