can anybody tell us, how to select 2nd max salary from
table.
my id is ashish.akk@gmail.com
Answers were Sorted based on User's Feedback
Answer / arun ashok
Select max(salary) from employee where salary not in (select
max(salary) from employee)
| Is This Answer Correct ? | 1 Yes | 1 No |
Select top 1 salary from table where salary in(select top 2
salary from table order by salary desc)order by salary
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / pravin
select max(sal) from emp
where sal=(select max(sal)
from emp
where sal<(select max(sal)
from emp))
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / syaam
select a.sal from emp a
where 2=(select count(distinct b.sal) from emp b
where a.sal<= b.sal)
for getting nth max sal ..replace 2 by n
all the best
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / swapnl
select max(sal) from emp_det where sal not in (
select max(sal) from emp_det);
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / kumar
1 My Second Answer.
Select Top 1 * From Tablename where salary in
(select top 2 salary from tablename order by salary desc)
order by salary asc.
| Is This Answer Correct ? | 0 Yes | 4 No |
How to convert a numeric expression from one data type to another?
What are statistics, under what circumstances they go out of date, how do you update them?
Can a stored procedure call another stored procedure. If yes what level and can it be controlled?
WRITE A FUNCTION TO DISPLAY THE OUTPUT OF AN EXISTING TABLE RANGE LIKE COMMAM SEPERATED VALUES LIKE RANGE1,RANGE2,...
Mention the different types of triggers?
What is the system function to get the current user's user id?
Difference between writing SQL query and stored procedure ?
15 Answers Cognizant, Infosys, TCS, Veritas,
What do mean by xml datatype?
What is in place upgrade in sql server?
create procedure proc1 (@a int) as begin if @a=1 create table #temp(a1 int) else create table #temp(a1 int) end while executeing the above code it shows error like '#temp already exist' .why it shows an error?
Define left outer join?
Delete duplicate records from the table?(Table must have unique id)
7 Answers TCS, Thomson Reuters,
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)