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

how to use AVG () aggregate function

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

Average Example in MS SQL server

Department Table

Department-table.png

Employee Table

EmployeeTable

SQL AVG () Aggregate Function Syntax

SELECT AVG(Specific_Column_name) FROM table_name

SQL Statement

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

from Department as d ,

     Employee  as e

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

     group by  d.DepartmentName

SQL Statement Result

sql-AVG()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