title: How can I update column with continuous value by GROUP?
body: <p>I am going to update a table with continuous value based on group.</p>
  
  <pre><code>   ItemNo       Group
    ---------------------
     null         group1      
     null         group1     
     null         group2      
     null         group2       
     null         group1      
     null         group2     
     null         group1    
     null         group2      
     null         group1      
  </code></pre>
  
  <p>This is an example table.
  I am trying to set the ItemNo field with continuous value by Group.
  So it will be set like this.</p>
  
  <pre><code>   ItemNo       Group
    ---------------------
     1            group1      
     2            group1     
     1            group2      
     2            group2       
     3            group1      
     3            group2     
     4            group1    
     4            group2      
     5            group1      
  </code></pre>
  
  <p>I tried with this query by it sets the value without considering Group.</p>
  
  <pre><code>DECLARE @id int
  SET @id = 0
  
  UPDATE table
  SET @id = ItemNo = @id + 1
  </code></pre>
  
  <p>How can I solve this problem?</p>
  
  <p>Thanks.</p>