write the query for find the top 2 highest salary in sql
server
Answers were Sorted based on User's Feedback
Answer / saritha
select distinct top 2 salary from EMP order by salary desc
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / adiseshu
select * from (
select dense_rank() over (order by salary desc) rno,* from
employees ) as a where rno in(1,2)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / mohan c v
select min(salary) from
(select top 2 salary from phani order by salary desc) as a
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / tanay chaudhary
select * from(select emp.*,Dense_Rank() over(order by salary desc) as ranking from emp)as e where e.ranking in(1,2)
//emp=table name
//salary=column name
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / santosh kumar
select Top 1 salary from ( select top 2 salary from
emp_table order by salary desc)temptable order by salary
desc.
| Is This Answer Correct ? | 13 Yes | 14 No |
Answer / santosh kumar
select Top 1 salary from ( select top 2 salary from
emp_table order by salary desc)temptable order by salary
asc.
| Is This Answer Correct ? | 11 Yes | 12 No |
SELECT TOP 1 salary FROM (SELECT DISTINCT TOP 2 salary FROM
employee ORDER BY salary DESC) a ORDER BY salary
| Is This Answer Correct ? | 3 Yes | 4 No |
Answer / neeraj sharma
select ename,sal from emp where rownum<=3 order by sal desc
Note:- every table has rownum column but it is hidden by
default you can see it by this
select rownum from your_table_name
| Is This Answer Correct ? | 3 Yes | 4 No |
Answer / vijayalaxmi m khot
select max(sal) from emp where sal=(select max(sal) from emp
where sal<(select max(sal) from emp));
| Is This Answer Correct ? | 1 Yes | 3 No |
Answer / shahid
select * from(select * from Employee order by salary desc) where rowNum<3
| Is This Answer Correct ? | 0 Yes | 3 No |
Show Practically Sql Server Views are updatable?
what is the difference in login security modes between v6.5 and 7.0? : Sql server database administration
hw you create table in sql using existing table and variable should be in specific order given ex : in old table empid empname empsal empage empbirthdate empaddrs like is there in new table we need it as EX: exmpname empage empaddrs empid empbirthdate like we want hw we create this as a table not view or nt reporting
What is difference between index seek vs. Index scan?
Is it possible to create a stored procedure that runs a query and outputs the results to a text file and allows me to add extra delimeters and static field info. If so How?
What is multi-statement table-value user-defined function?
How to create a ddl trigger using "create trigger" statements?
Can we rollback records deleted by a truncate statement?
3 Answers CarrizalSoft Technologies, United Healthcare,
What is an indice?
you are provided with the single table having say 4 col ie fname lname age city , now the all records with displying of only fname and lname is required but in this format say my name is abhay khanna it will come like this abhay-khanna rahul-roy gaurav-singh the above format is required
how to get rank of diffrent student in same table based on newly inserted row in sql server2008
Which data type columns are the best candidates for full-text indexing?
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)