find 2nd highest salary of person using cursor concept?
Answers were Sorted based on User's Feedback
Answer / amruta dash
select max(salary) from tbl where salary not in (select max
(salary) from tbl);
| Is This Answer Correct ? | 11 Yes | 6 No |
Answer / jcreddy
select e1.salary from employee e1
where 1 = (select count(salary) from employee e2 where
e1.salary < e2.salary)
order by marks asc
-- by changeing from '<', to '>' you will get min salary
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / manju
DECLARE authors_salary CURSOR
select top2(salary) from tb_employee order by desc salary
open author_salary
FETCH NEXT FROM authors_salary into @topsalary
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / krish
select max(sal) frem tbl where sal <(select max(sal) from tbl;
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / pawan
select * from emp a where 2=(select count(distinct(sal)) from emp b where a.sal<=b.sal);
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / b.mamatha
select * from tabl1 where salary=(select max(salary) from
tabl1 where salary<(select max(salary) from tabl1)
| Is This Answer Correct ? | 0 Yes | 1 No |
What is the recovery model? List the types of recovery model available in sql server?
What are the 2 types of classifications of constraints in the sql server?
you notice that the transaction log on one of your databases is over 4gb the size of the data file is 2mb what could cause this situation, and how can you fix it? : Sql server administration
How to count rows with the count(*) function in ms sql server?
Can a synonym name of a table be used instead of a table name in a select statement?
What is normalization and what are the different forms of normalizations?
Explain what is the difference between a local and a global temporary table?
What is the osql utility?
Mention the different types of triggers?
What are the different editions available in sql server 2000?
How to drop an existing table?
Explain syntax for disabling triggers?
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)