Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how to find the second highest salary from emp table?

Answer Posted / bharath reddy

These qeries give you second higest salary

select e.sal from emp e,emp d where d.sal>e.sal
group by e.sal
having count(e.sal)=2
;

SAL
-----
3000

(or)

select distinct e.sal from emp e where (select count(sal)
from emp d where d.sal>e.sal)=1;

SAL
-----
3000

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of stored procedures?

977


Which is better trigger or stored procedure?

881


What is anonymous block in sql?

1076


What plvcmt and plvrb does in pl/sql?

1251


What is pivot in sql?

873


What is a sql trace file?

979


What do you understand by case manipulation functions?

954


How do you rename a table in sql?

1034


Explain the difference between rename and alias?

966


Can we use ddl statements in stored procedure?

1097


Which version of sql do I have?

1000


What is data modelling in sql?

964


What is graph sql?

938


what is a composite key ? : Sql dba

995


What information is needed to connect sql*plus an oracle server?

981