title: How to designate specified records based on the date in huge Oracle table
body: <p>I have a huge table, 500 million records. I've got to divide this table into groups (partitions) on the base of 4 attributes.</p>
  
  <p>Within each group I have to pick (set a flag) newest record and subsequent records if the difference in date is greater than or equal to 7 days (choose the latest entry from 7-days period). </p>
  
  <p>I think the table is too big to make calculations on it. Should I split it into several smaller ones? But all records of one group have to be in the same table.</p>
  
  <p>Is there any way to designate appropriate records using only SQL (without fetching it to PL/SQL arrays)? This is a one-off operation.</p>
  
  <p>Do you have any idea how to solve this problem?</p>
  
  <p>Example (one group - attributes and date dd-mm-yyyy format):</p>
  
  <ol>
  <li>[A1 A2 A3 A4] 08-05-2018 (flag 1 - newest one)</li>
  <li>[A1 A2 A3 A4] 06-05-2018 (flag 0 - difference less than 7 days)</li>
  <li>[A1 A2 A3 A4] 01-05-2018 (flag 1 - difference greater/equal 7 days)</li>
  <li>[A1 A2 A3 A4] 30-04-2018 (flag 0 - difference less than 7 days - relative to record 3)</li>
  <li>[A1 A2 A3 A4] 10-04-2018 (flag 1 - difference greater/equal 7 days - relative to record 3)</li>
  </ol>