1. Finds the two highest salaries from table "emp".
Code:
select a.empno,a.sal
from emp a
where 2>
(
select count(*)
from emp
where sal>a.sal
);
2. Finds the two lowest salaries from table "emp".
Code:
select a.empno,a.sal
from emp a
where 2>
(
select count(*)
from emp
where sal<a.sal
)
Welcome to the GEEK world, best place where you find topic about latest cutting edge technology on website and mobile. Learn and grow your knowledge with the information and tutorials about Website designing, CSS tutorials, Java Script tutorials, Ruby tutorials, ROR tutorials, HTML tutorials, HTML5 , JQuery, Javascript tutorials, Photoshop tutorials, Flash, games tutorials, Cheat sheets, Design tools, Action Scripts as well as MySql, Oracle and many more in a easy way to use and understand.
Subscribe to:
Post Comments (Atom)
3 comments:
for mysql what to do?
plz mail me at gajendrapratap2012@gmail.com
Thanks....
In Mysql you can use order by and limit. For eg.
select * from table_name order by some_field [asc|desc] limit 5
will select 5 records as per ASC / DESC order.
Hope it helps.. :)
thanks ..
Post a Comment