http://feeds.feedburner.com/SpendYourTimeHere-Once

Current Affiares

Sunday, July 15, 2012

How to get a second largest salary from database?

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)

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

My Blog List

Popular Posts

All Rights Reserved To SYTHONCE. Ethereal theme. Powered by Blogger.