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

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.

29 Responses to AVG() function in SQL Server

  1. Pingback: hi-lo,ไฮโลออนไลน์,สูงต่ำ

  2. Pingback: 바카라

  3. Pingback: google analytics wordpress

  4. Pingback: 온라인카지노

  5. Pingback: How to watch Rugby World Cup 2019 live stream online instantly

  6. Pingback: https://www.wasseem.org/

  7. Pingback: https://www.hokybos.com

  8. Pingback: Accountant in Tampa FL

  9. Pingback: official website

  10. Pingback: ประยุทธ์ จันทร์โอชา

  11. Pingback: New build Property Investment Alicante

  12. Pingback: Lexus Near Greensboro NC

  13. Pingback: http://altto.pl/gazeta-wyborcza-plock-192-2013-998.php

  14. Pingback: w88.com - a-thể thao

  15. Pingback: Pre-Market Stocks Gold Silver Update Today New Futures Exchange for Gold

  16. Pingback: slotjackpot168

  17. Pingback: Drogen kaufen

  18. Pingback: ebenin amini türkce dublaj izle

  19. Pingback: Industry Report

  20. Pingback: w88 world

  21. Pingback: cdr qq

  22. Pingback: fifia55

  23. Pingback: ufabet

  24. Pingback: mejaqq

  25. Pingback: iPhone XR Screen Replacement for LCD Digitizer Amazon Best Seller

  26. Pingback: Sydney

  27. Pingback: car window signs

  28. Pingback: agen qiuqiu99

  29. Pingback: https://www.klikdokter.com/

Leave a Reply