title: I need to add a column that assigns row numbers to each record
body: <p>I am trying to add a column that assigns row numbers to each record</p>
  <p>I made changes to the code to add the desired column</p>
  <p>But I was getting duplicated row numbers. How do I get unique row numbers?
  .</p>
  <pre><code>**Note: This code can be executed in the SQL editor like that. It needs no sample data**
  
  select distinct trunc(GenerateTimeBy1Day,'day') as claim_eff_date, trunc(GenerateTimeBy1DayPlus20,'day') as bwe_to_completeby from
  (
      select from_dt + (level - 1)/1 as GenerateTimeBy1Day, (from_dt + (level - 1)/1) + 20 as GenerateTimeBy1DayPlus20 
      from (select from_dt
          ,to_dt
          ,to_dt - from_dt + 1 as days_between    
      from (select to_date('03-Jan-2021') as from_dt
                 , to_date('30-Jan-2021') as to_dt 
            from dual))
      connect by (level - 1) &lt;= days_between  
  )
  order by claim_eff_date
  </code></pre>
  <p>I made these changes to the code to add the desired column</p>
  <pre><code>**Note: This code can be executed in the SQL editor like that. It needs no sample data**
  
  select distinct trunc(GenerateTimeBy1Day,'day') as claim_eff_date, trunc(GenerateTimeBy1DayPlus20,'day') as bwe_to_completeby, row_number() 
  over (PARTITION BY trunc(GenerateTimeBy1Day,'day'), trunc(GenerateTimeBy1DayPlus20,'day') ORDER BY trunc(GenerateTimeBy1Day,'day')) as row_number from
  (
      select from_dt + (level - 1)/1 as GenerateTimeBy1Day, (from_dt + (level - 1)/1) + 20 as GenerateTimeBy1DayPlus20 
      from (select from_dt
          ,to_dt
          ,to_dt - from_dt + 1 as days_between    
      from (select to_date('03-Jan-2021') as from_dt
                 , to_date('30-Jan-2021') as to_dt 
            from dual))
      connect by (level - 1) &lt;= days_between  
  )
  order by claim_eff_date
  </code></pre>
  <p>But I am getting</p>
  <pre><code>Row_Number
  ----------
  1
  1
  2
  3
  4
  5
  6
  1
  1
  2
  3
  </code></pre>
  <p>How do I get unique row numbers?</p>
  <pre><code>Row_Number
  ----------
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  </code></pre>