GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Oracle

 Print  |  
Question:  Multi Row Sub-Queries

Answer: Query 1.
SELECT sal FROM emp e WHERE sal < any (SELECT sal FROM emp
WHERE empno=e.mgr)
(o/p:11 row)

Query 2.
SELECT SAL FROM emp e WHERE sal < any (SELECT sal FROM emp
WHERE mgr=e.empno)
(o/p:1 row)

What is the difference between the above 2 queries.


September 09, 2008 04:20:17 #1
 todeepakmalhotra   Member Since: September 2008    Total Comments: 5 

RE: Multi Row Sub-Queries
 
These both are correlated subqueries.

In the first one, we are knowing the salaries of employees who are earning less than there manager.


In the second one we are knowing about the salaries of managers who are earning less than their employees whom they manage.
     

 

Back To Question