select the 3rd maximum salary from sql server database if 4
(just an example In practically I may not know the exact
situation) of the highest salaries are equal.
Answers were Sorted based on User's Feedback
Answer / shekhar
SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP 3 salary
FROM tblSalary
ORDER BY salary DESC) S
ORDER BY salary
| Is This Answer Correct ? | 23 Yes | 4 No |
Answer / sumesh.s.g
--Sumesh.S.G--
SELECT TOP 1 salary
FROM (select top 3 Salary
from dbo.TBL_Employee
order by Salary desc) as TemTable order by Salary asc
--Happy coding--
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / jey ganesh
select min(sal) from employee where sal in(
select top 3 sal from employee order by sal desc)
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / kiran
select empid,salary
from (select distinct empid,salary,
Dense_Rank() over(order by salary desc) as Rank
from dbo.EmpSalary) b
where b.rank=3
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / sandeep saxena
CREATE procedure Proc_Loaddata_Text (@File_path nvarchar
(255),@Table_Name varchar(100)) AS
DECLARE @SQLString NVARCHAR(4000)
/* Build Command*/
SET @SQLString =N'Bulk Insert ['+@Table_Name+'] from ' +
N'N''' + @File_path + N''' with (FIELDTERMINATOR=''|'',
ROWTERMINATOR = ''\n'')'
--print @SQLString
/* Execute */
EXEC (@SQLString)
GO
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / vijay saxena
SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP 3 salary
FROM tblSalary
ORDER BY salary DESC)
| Is This Answer Correct ? | 0 Yes | 2 No |
Answer / sunil nair
SELECT EmpID,Salary from tblSalary a where 3=(select count
(distinct EmpID) from tblSalary b where b.empid>=a.empid)
For any database
| Is This Answer Correct ? | 2 Yes | 5 No |
Answer / sunil nair
SELECT EmpID,Salary from tblSalary a where 3=(select count
(EmpID) from tblSalary b where b.empid=a.empid)
for any RDBMS
| Is This Answer Correct ? | 2 Yes | 13 No |
What is the purpose of forms?
How can you find out how many rows returned in a cursor?
What is row_number () and partition by in sql server?
What do you know about normalization and de- normalization?
Explain the difference between functions and stored procedures in sql server?
What is model database? : SQL Server Architecture
Tell me about builtinadministrator?
What is built-in function?
What are the difference between primary key and unique key? : sql server database administration
Why is there a performance difference between two similar queries where one uses union and the other uses union all?
What is a document index?
How do I start sql server?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)