Professional Documents
Culture Documents
Interview
Interview
from employee a
right outer join employee b
on a.employee_id = b.manager_id;
SELECT * FROM employee e where rowid = (SELECT max (rowid) FROM employee);--last
record in table
SELECT * FROM account_details a;-- order by a.trans_amount desc;
SELECT * FROM account_details a where 2= (select count( distinct trans_amount)from
account_details a1
where a.trans_amount<=a1.trans_amount);-- 2nd last transaction amount
SELECT min(trans_amount) FROM(SELECT distinct (a.trans_amount) FROM account_details
a order by a.trans_amount desc) WHERE rownum<=2;-- 2nd last transaction amount
SELECT * FROM account_details a where rownum<=4 order by a.trans_amount desc;-- top
4 rows
SELECT * FROM employee e where rowid =(select max(rowid) from employee e1 where
e.employee_id=e1.employee_id);--get distinct rows without usinfg DISTINCT key