SUM() function in 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

About vivekjohari

Database Consultant with more than 11.5 years of experience in database designing & programming and DBA related activities.  Had good experience on different databases like SQL Server, MySQL & Oracle, Azure SQL &  Big Data.
This entry was posted in SQL Functions, SQL Server and tagged . Bookmark the permalink.

31 Responses to SUM() function in SQL Server

  1. Pingback: w88 club

  2. Pingback: w88

  3. Pingback: murat fedakar dolandirici

  4. Pingback: low doc home loans

  5. Pingback: United Medicare Advisors

  6. Pingback: cryptocurrencies

  7. Pingback: Bundles Wigs Weaves

  8. Pingback: jaguarqq

  9. Pingback: w888

  10. Pingback: didi promo code

  11. Pingback: Creative Agency in Orlando

  12. Pingback: EmpireMarket-Links.com

  13. Pingback: https://www.olx.pl/

  14. Pingback: w88th

  15. Pingback: custom cornhole board set

  16. Pingback: Darknet Drogen

  17. Pingback: Samsara Market

  18. Pingback: Samsara Market

  19. Pingback: Slager hengelo

  20. Pingback: huong dan choi ca do bong da online

  21. Pingback: Sea Games 2019

  22. Pingback: megapoker99

  23. Pingback: w88 casino online

  24. Pingback: granice.info

  25. Pingback: Leif

  26. Pingback: poker 99

  27. Pingback: tilecacuoc

  28. Pingback: data sgp

  29. Pingback: huong dan dang ky fun88

  30. Pingback: fowling rules

  31. KADİR says:

    hello thank you 🙂

Leave a Reply