title: sql server query to divide rows in a column into four groups or columns
body: <p>I have a column in a table, and I want to divide it's rows into four equal groups (or columns, whichever is easier to implement) with random allocation.</p>
  
  <p>Suppose the rows of column look like: </p>
  
  <pre><code>**id**
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  11
  12
  </code></pre>
  
  <p>I would like the output to be like:</p>
  
  <pre><code>*id_A  id_B  id_C  id_D*
   3     8     5     1
   6     2     4     12
   11    9     7     10
  </code></pre>
  
  <p>One possible way of doing it is displaying the rows in random order using newid() and then selecting every 5th record alternatively for each group. Is there any other simpler way to achieve the desired outcome?</p>