select top 3 salary- sql

create table Myinfo

CREATE TABLE [dbo].[Myinfo](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [nchar](50) NULL,
[Salary] [int] NULL,
CONSTRAINT [PK_Myinfo] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

Insert values  into Myinfo

insert into myinfo values (‘fff’,35)

insert into myinfo values (‘fff’,222)

insert into myinfo values (‘fff’,444)

SQL query to findout top 3 highest salary

select top 3 id,name,salary from Myinfo order by salary desc

SQL query to findout top 3 minimum salary

select top 3 id,name,salary from Myinfo order by salary asc

 

 

 

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s