How to get a second largest salary from database?
Below will work in all database----
select * from tablename t where
2 =(select count(distinct id) from tablename where t.id<=id)
(select top 3 id from tablename order by id desc) tb)
Below will work in all database----
select * from tablename t where
2 =(select count(distinct id) from tablename where t.id<=id)
Below will work in sql server and mysql only ---
select * from tablename where
id = (select min(id) from (select top 3 id from tablename order by id desc) tb)
No comments:
Post a Comment