Get Sum of Row in SQL Server

This blog defines the sum of rows in SQL Server.

CREATE TABLE EmployeeSalary

(
      ID INT PRIMARY KEY NOT NULL,

      NAME varchar(50),

      BASIC INT,

      HRA INT,

      BONUS INT

)

INSERT INTO EmployeeSalary(ID,NAME,BASIC,HRA,BONUS) values (1001,'Manish Agrahari',1000,500,200);

INSERT INTO EmployeeSalary(ID,NAME,BASIC,HRA,BONUS) values (1002,'Amit Singh',1000,500,200);

INSERT INTO EmployeeSalary(ID,NAME,BASIC,HRA,BONUS) values (1003,'Bill Gates',2000,800,300); 

INSERT INTO EmployeeSalary(ID,NAME,BASIC,HRA,BONUS) VALUES (1004,'Raju Rastogi',2000,800,500);

SELECT * FROM EmployeeSalary


Image1.jpg

SELECT ID,NAME, BASIC,HRA,BONUS,(BASIC+HRA+BONUS)as Total_Salary

FROM EmployeeSalary

Image2.jpg

Ebook Download
View all
Learn
View all