title: Cumulative Total in MS Sql server
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/860966/calculate-a-running-total-in-sqlserver">Calculate a Running Total in SqlServer</a>  </p>
  </blockquote>
  
  
  
  <p>I need to get the cumulative (running) total of a column in ms-sql server. I.e. if there is a column named “Marks”, then corresponding to each row cumulative sum will the sum of current and previous rows. Can we attain the result without using joins? Because my query is pretty big.</p>
  
  <p>I have included a sample table and data:</p>
  
  <pre><code>CREATE TABLE "SCORE_CHART" 
     (    
          "STUDENT_NAME" NVARCHAR(20), 
          "MARKS" INT
     )
  
  INSERT INTO SCORE_CHART (STUDENT_NAME, MARKS) VALUES ('STUD1', 95);
  INSERT INTO SCORE_CHART (STUDENT_NAME, MARKS) VALUES ('STUD2', 90);
  INSERT INTO SCORE_CHART (STUDENT_NAME, MARKS) VALUES ('STUD3', 98);
  
  SELECT STUDENT_NAME, MARKS FROM SCORE_CHART;
  </code></pre>
  
  <p>Expected result:
  <img src="https://i.stack.imgur.com/4LWdC.jpg" alt="enter image description here"></p>
  
  <p>In oracle it’s easy to write like:</p>
  
  <pre><code>SELECT 
    STUDENT_NAME,
    MARKS,
    SUM(MARKS) OVER (ORDER BY STUDENT_NAME) CUM_SUM
  FROM SCORE_CHART
  ORDER BY STUDENT_NAME;
  </code></pre>
  
  <p>Thanks in advance.</p>