find 2nd highest salary of person using cursor concept?
Answer Posted / 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 |
Post New Answer View All Answers
Is mysql better than sql server?
What will be the value of @@fetch_status if a row that was a part of the cursor resultset has been deleted from the database after the time the stored procedure that opened the cursor was executed?
What are the types of normalization?
Where are full-text indexes stored?
What do you understand by mirroring?
what are the basic functions for master, msdb, model, tempdb and resource system databases? : sql server database administration
Where are stored procedures in sql server?
Does hive support indexing?
What are the differences between char and varchar in ms sql server?
What is indexed view? How to create it?
How to create stored procedures with parameters in ms sql server?
Give the query of getting last two records from the table in SQL SERVER?
Is it possible to have clustered index on separate drive from original table location?
How to use old values to define new values in update statements in ms sql server?
What is mapping schema?