0 Replies - 5229 Views - Last Post: 06 February 2013 - 04:46 AM

#1 rnty  Icon User is online

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 168
  • Joined: 14-August 12

select alternate rows and 3rd maximum salary

Posted 06 February 2013 - 04:46 AM

Someone please explain how following queries execute.

//alternate rows
select * from emp where rowid in (select decode(mod(rownum,2),0,rowid, null) from emp); 

//3rd max salary
select distinct sal from emp e1 where 3 = (select count(distinct sal) from emp e2 where e1.sal <= e2.sal); 

//top n
select * from emp where rownum <= &n; 

//bottom n
select * from emp minus select * from emp where rownum <= (select count(*) - &n from emp); 



I understand the operators, clauses and statements used, all I am confused about is how are they being executed internally.
Thank You

This post has been edited by rnty: 06 February 2013 - 04:47 AM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1