Skip to content
Loading
Running query in sql server
  • Sai Reddy
    Thank you. Here i found an simple solution.
     
    With partition------
    select *,sum(salary) over ( order by id )as runningsal from Employees
     
    Without partition------ 
    select *,sum(salary) over (partition by gender order by id )as runningsal from Employees
     
    +3
  • Amit Kumar
    Hi,
         Please use the below query. 
    1. SELECT ID (SELECT SUM (ID) FROM EMPLOYEE employee   
    2. WHERE tbl.ID <=EMP.ID) AS 'RUNNING TOTAL Value'  
    3. FROM tbl EMP  
     And for more details same example use the below link.
     
    https://www.dotnettechpoint.com/2018/03/calculate-running-total-in-sql-serverr.html 
    +1
  • Rajeev Punhani

    Hi Sai,

    Please find the below query.

    1. SELECT t.ID,COALESCE ((t.Value+t1.Value),t.Value) as Value  
    2. FROM Sample t  
    3. left JOIN Sample t1 ON t.ID = t1.ID+1 order by t.ID;  
    +2