Transact-SQL Get Average Maximum Minimum Values by Group Examples


Tool : Microsoft SQL Server Management Studio (SSMS)

Transact-SQL Create Database And Create Table Examples

Transact-SQL Insert Data Into Table Examples

Transact-SQL Retrieve Data From A Table Examples

Average Records of The Column [Salary] in The Table [Employees] by Group

/* Average records of the column [Salary] in the table [Employees] by group */

Use [SampleDB]
Go
Select Gender,AVG(Salary) As Average_Salary
From [Employees]
Group By Gender


Get The Maximum Record of The Column [Salary] in The Table [Employees] by Group

/* Get the maximum record of the column [Salary] in the table [Employees] by group */

Use [SampleDB]
Go
Select Gender,MAX(Salary) As Maximum_Salary
From [Employees]
Group By Gender


Get The Minimum Record of The Column [Salary] in The Table [Employees] by Group

/* Get the minimum record of the column [Salary] in the table [Employees] by group */

Use [SampleDB]
Go
Select Gender,MIN(Salary) As Minimum_Salary
From [Employees]
Group By Gender


張貼留言

0 留言