Find Cumulative Salary of an Employee in SQL Server

Hi Programmers, welcome to ozanecare software blogs. this article is about to give different queries to calculate cumulative salary of employee using Microsoft SQL server. Let’s see the Queries.

1.All the Records of Emp Table. See below image.

2. Calculate cumulative salary with the help of sum aggregate function. OVER clause and order by clause. but below query , if salaries are duplicate then cumulative sum calculate duplicate. see below image.

3.Range function unbounded preceding and current row calculate duplicate salaries and duplicate cumulative sum.

4.To calculate unique cumulative salaries we must include Rows and unbounded preceding and current row. see below image.

5.To calculate cumulative salary with department-wise , we must include partition by. see below image.

Happy Queries…Thanks

Post Author: adama