title: Generate Row Number for every 3 rows
body: <p>I want generate number for every three rows </p>
  
  <pre><code>CREATE TABLE #test(period INT)
  
  INSERT INTO #test
  VALUES      (602),(603),(604),(605),(606),(607),(608),(609)
  </code></pre>
  
  <p>I know we can generate sequence using <code>row_number</code> window function or <code>while</code> loop or <code>cursor</code> </p>
  
  <pre><code>SELECT period,
         ( Row_number()OVER(ORDER BY period) - 1 ) / 3 + 1
  FROM   #test 
  </code></pre>
  
  <p><strong>Result;</strong></p>
  
  <pre><code>+--------+-----+
  | period | seq |
  +--------+-----+
  |    602 |   1 |
  |    603 |   1 |
  |    604 |   1 |
  |    605 |   2 |
  |    606 |   2 |
  |    607 |   2 |
  |    608 |   3 |
  |    609 |   3 |
  +--------+-----+
  </code></pre>
  
  <p>Is there any other way to achieve this <strong>mathematically</strong>. There will not be any gaps between the periods</p>