Max() function in SQL Server

Max():- This function gives the maximum value of the selected column

Syntax:-

Select Max (col1) from table_name

In this article, we are going to use the following table for the 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′,’Abhinav’,’Golwalkar’,’abhinav@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, query to get the maximum salary of an employee from the table Employee is given below:-

Select Max (salary) from Employee

It will gives the following result:-

320000

DMCA.com


Discover more from Technology with Vivek Johari

Subscribe to get the latest posts sent to your email.

26 comments

  1. Pingback: 카지노사이트
  2. Pingback: bong88
  3. Pingback: Website
  4. Pingback: Nachfolger
  5. Pingback: Tochka Market
  6. Pingback: Drogen kaufen
  7. Pingback: Darknet
  8. Pingback: new santali 2013
  9. Pingback: qiuqiu99
  10. Pingback: Togel OnLine
  11. Pingback: manele noi 2020
  12. Pingback: poker 99

Leave a Reply