SQL Query To Increase Salary By Percentage For All Employees In A Table

Introduction

Sometimes we may need to increase the current column value by Percentage. The very good example is Salary in an organization. We need to update the salary of each employee based on the Hike Percentage.

Increasing Salary By Percentage

In this example, lets assume the Hike percentage is equal for all employees, and I am counting 15 Percentage as Hike. Lets create the table and insert some records.

CREATE TABLE [Details].Employees
(
	Id INT IDENTITY(1,1), 
	FullName VARCHAR(50), 
	Salary FLOAT
)

Inserting records into the Employees Table,

INSERT INTO [Details].Employees VALUES 
(
	'Sundaram', 
	1000.00
),
(
	'Saravana Kumar', 
	2000.00
),
(
	'Pushparaj', 
		3000.00
),
(
	'Karthik K',
	4000.00
),
(
	'Akilan', 
	5000.00
)

Lets select all the records from the table Employee.

SELECT * FROM [Details].Employees
Fig.1 All Records from the table Employee

Now lets update the salary column by 15 percentage for all records.

UPDATE Details.Employees
SET Salary = salary * 1.15

Select all the record from the table,

Fig. 2 Salary updated after applying increment

Conclusion

In this article, we discussed about how to increase the value by applying some percentage. I hope you all got some idea and found this article useful. Please share your feedback in the comment section.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Website Built with WordPress.com.

Up ↑

%d bloggers like this: