SUM() function in SQL Server

SQL Functions SQL Server
Sum():- This function is used to get the sum of values of the specified numeric column.

 Syntax:-

 Select Sum (column_name) from tablename

Example:-

In this article, we are going to use the following table for the examples:-

CREATE TABLE [dbo]. [Employee](
[Empid] [Int] IDENTITY (1, 1) NOT NULL Primary key,
[EmpNumber] [nvarchar](50) NOT NULL,
[EmpFirstName] [nvarchar](150) NOT NULL,
[EmpLAStName] [nvarchar](150) NULL,
[EmpEmail] [nvarchar](150) NULL,
[Salary] [int] NULL
)

We insert following data into the above tables:-
Insert Into Employee (EmpNumber,EmpFirstName,EmpLAStName,EmpEmail,salary)
Values(‘A001′,’Vivek’,’Johari’,’samir@abcmail.com’,200000)

Insert Into Employee (EmpNumber,EmpFirstName,EmpLAStName,EmpEmail,salary)
Values(‘A002′,’Abhinav’,’Golwalkar’,’abhinav@abcmail.com’,100000)

Insert Into Employee (EmpNumber,EmpFirstName,EmpLAStName,EmpEmail,salary)
Values(‘A003′,’Neha’,’Sharma’,’neha@abcmail.com’,300000)

Insert Into Employee (EmpNumber,EmpFirstName,EmpLAStName,EmpEmail,salary)
Values(‘A004′,’Chandra’,’Singh’,’vivek@abcmail.com’,320000)

Insert Into Employee (EmpNumber,EmpFirstName,EmpLAStName,EmpEmail,salary)
Values(‘A005′,’Avinash’, ‘Dubey’,’avinash@abcmail.com’,250000) 

For example, query for finding the total amount of salary given by the company to its employee is given below:-

 Select sum (salary) from Employee

 Result

 1170000

DMCA.com

31 thoughts on “SUM() function in SQL Server

  1. Pingback: w88 club
  2. Pingback: w88
  3. Pingback: low doc home loans
  4. Pingback: cryptocurrencies
  5. Pingback: jaguarqq
  6. Pingback: w888
  7. Pingback: didi promo code
  8. Pingback: w88th
  9. Pingback: Darknet Drogen
  10. Pingback: Samsara Market
  11. Pingback: Samsara Market
  12. Pingback: Slager hengelo
  13. Pingback: Sea Games 2019
  14. Pingback: megapoker99
  15. Pingback: w88 casino online
  16. Pingback: granice.info
  17. Pingback: Leif
  18. Pingback: poker 99
  19. Pingback: tilecacuoc
  20. Pingback: data sgp
  21. Pingback: fowling rules

Leave a Reply