Posted by : Anwar Hossain
Category : Basic sql tutorial for Beginner

How to use SUM () aggregate function

Dear viewer I will show how to use SUM () aggregate function. SUM () aggregate function return the total value of any numeric column that means a single sum value result return. In this solution I have used two table one Department table and another Employee I will find total salary according to Department wise .Such as total salary of production department.

Sum Example in MS SQL server

Department Table

Department-table.png

Employee Table

EmployeeTable

SQL Sum() Aggregate Function Syntax

SELECT Sum(Specific_Column_name) FROM table_name

SQL Statement

SELECT d.DepartmentName, sum(e.Salary ) as  TotalSalery

from Department as d ,

     Employee  as e

     WHERE d.ID = '1' and e.DepId = '1'

     group by  d.DepartmentName

 

SQL Statement Result

sql-Sum()Function-example



Realted Article Headline

How to use MIN () Aggregate Function
How to use MAX () Aggregate Function
How to use SUM () aggregate function
how to use AVG () aggregate function
How to use sql alies for sql table
SQL BETWEEN Operators for retrieving range values
FULL OUTER JOIN using two tables in SQL server
LEFT JOIN using two tables in SQL server
How to join two table in sql server

Article Category

How to create asp.net control dynamically
Learn HTML for beginner
DataList example in C Sharp
Mail sending in asp.net c#
State Management in ASP C #
Basic sql tutorial for Beginner
DataTable example in ASP.Net C#
How to use LINQ in ASP.NET C#
asp.net c # basic tutorial
How to use ajax toolkit in asp.net C#
How to use different types of validation control using asp.net c#
How to use grid view in asp.net c#
Protected by Copyscape Online Plagiarism Detection