title: SQl Server Query with add column value in rows as addition
body: <p>I have a Table ExamSubjects</p>
  
  <pre><code>ExId,SubId,GroupId,SubOrder,NoQuestions
  1    2     1       1      60
  1    3     1       2      60
  1    1     2       3      120
  </code></pre>
  
  <p>I want an output in way that column NoQuestions must be added top next column based on groupId</p>
  
  <pre><code>ExId SubId,StartNo,EndNo
  1     2     1       60
  1     3     61      120
  1     1     1       120
  </code></pre>
  
  <p>Is There any other method other than using loop and temp table.Currently i am using while loop to generate the output</p>