GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL Plus
Go To First  |  Previous Question  |  Next Question 
 SQL Plus  |  Question 10 of 132    Print  
Explain UNION, MINUS, UNION ALL and INTERSECT

Answer posted by Scott on 2005-05-25 18:32:51: UNION - the values of the first query are returned with the values of the second query eliminating duplicates. 
MINUS - the values of the first query are returned with duplicates values of the second query removed from the first query. 
UNION ALL - the values of both queries are returned including all duplicates 
INTERSECT - only the duplicate values are returned from both queries.



  
Total Answers and Comments: 4 Last Update: December 07, 2006   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
May 25, 2005 18:32:51   #1  
Scott        

RE: Explain UNION, MINUS, UNION ALL and INTERSECT
UNION - the values of the first query are returned with the values of the second query eliminating duplicates.
MINUS - the values of the first query are returned with duplicates values of the second query removed from the first query.
UNION ALL - the values of both queries are returned including all duplicates
INTERSECT - only the duplicate values are returned from both queries.

 
Is this answer useful? Yes | No
September 10, 2005 05:32:27   #2  
Pankaj & Sunil        

RE: Explain UNION, MINUS, UNION ALL and INTERSECT
Union Will eliminate duplicate rows from both the tables which are participating in the union operation
 
Is this answer useful? Yes | No
September 16, 2005 01:18:46   #3  
Atal Member Since: September 2005   Contribution: 3    

RE: Explain UNION, MINUS, UNION ALL and INTERSECT

UNION: Take the common record once( No Duplicate)

UNION ALL : Takes Duplicates also

Exampl : Say there is EMP having 14 reconds then...

select count(1) from (select ename from emp) returns 14

select count(1) from (select ename from emp union select ename from emp e1) returns 14

But

select count(1) from (select ename from emp union All select ename from emp e1)

returns 28.


 
Is this answer useful? Yes | No
December 07, 2006 06:32:55   #4  
rampratap409 Member Since: September 2006   Contribution: 111    

RE: Explain UNION, MINUS, UNION ALL and INTERSECT

UNION: Take the common record once( No Duplicate)

UNION ALL : Takes Duplicates also

Minus: Result of first query - result of second query

examle

select * from emp where rownum< 9;

minus

select * from emp where rownum<9;

this will display 9th row of emp

Intersect: common result of both query


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape