C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
iOS
Java
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
13
Reply
select 2nd highest salary
Ravi Patel
11y
2.6k
1
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
SELECT TOP 1 salary FROM ( SELECT DISTINCT TOP 2 salary FROM employee ORDER BY salary DESC) a ORDER BY salary
Ramesh Maruthi
11y
3
The simplest way isselect max(sal) from Salary where sal in(select top 2 sal from Salary order by sal desc).
Rajesh Pathakoti
11y
2
Select Salary from Employee A where 2=(select COUNT(*) from Employee B where B.Salary>=A.Salary)
Ranjit Powar
11y
1
Select max(salary) from (select top 2 distinct salary from table order by desc )
vicky bhoir
8y
0
??? runman7942.com ?? ???? ???? ?? ????
Jiseo Lee
9y
0
Select Top 1 Salary From ( select top 2 salary from Table_name order by(salary) Desc )A Order By(Salary) Asc
Rahul Prajapat
10y
0
Select Top 1 Salary From ( select top 2 salary from Table_name order by(salary) Desc )AOrder By(Salary) Asc
Pankaj Kumar Choudhary
10y
0
select * from table order by salary desc offset 2 rows fetch next 1 rows only
Satyam Verma
10y
0
SELECT DISTINCT TOP 2E.Salary FROM Employee E EXCEPT SELECTMAX(Salary) FROM Employee ORDER BY E.Salary DESC
Tanul Bhasin
11y
0
Select Amount from [PurchaseDetails] A where 2=(select COUNT(*) from [PurchaseDetails] B where B.Amount>=A.Amount) note :-PurchaseDetails is a table and Amount is a column more help contact:-----
[email protected]
Rajesh kumar
11y
0
Select * from orders(NOLocK) order by Freight desc; WITH CTE as ( select ROW_NUMBER() Over (Order by Freight DESC) as RowNum,OrderID, CustomerID, Freight, EmployeeID from Orders) Select * FRom CTE where RowNum=2The above example is from northwind database
swatantra singh
11y
0
select max(salary) from employee where emp_id not in (select TOP(n) from employee order by salary desc )In your case n =1,as you want 2nd highest salary .To get 3 highest or so on just replace n acordingly.
Ashish
11y
0
SQL Queries in Oracle, select min(salary) from (select * from (select * from employee order by SALARY desc) where rownum < 3)SQL Queries in SQL Server, select min(SALARY) from (select top 2 * from employee) aSQL Queries in MySQL, select min(SALARY) from (select * from employee order by salary desc limit 2) afor more imp Sql query http://dotnet-munesh.blogspot.in/2013/12/important-sql-query.html
Munesh Sharma
11y
0
Message