AVG() function in SQL Server

SQL Functions SQL Server
Avg():- This function is used to get the average value of a numeric column

Syntax:-

      SELECT AVG(column_name) FROM table_name

In this article, we are going to use the following table for some 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′,’Amit’,’Kumar’,’amit@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,

      Select AVG(salary) from employee

will give the given result:-

234000   

29 thoughts on “AVG() function in SQL Server

  1. Pingback: 바카라
  2. Pingback: 온라인카지노
  3. Pingback: official website
  4. Pingback: slotjackpot168
  5. Pingback: Drogen kaufen
  6. Pingback: Industry Report
  7. Pingback: w88 world
  8. Pingback: cdr qq
  9. Pingback: fifia55
  10. Pingback: ufabet
  11. Pingback: mejaqq
  12. Pingback: Sydney
  13. Pingback: car window signs
  14. Pingback: agen qiuqiu99

Leave a Reply