GeekInterview.com
Series: Subject: Topic:
Question: 124 of 133

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.
Asked by: Interview Candidate | Asked on: Sep 10th, 2005

Editorial / Best Answer

Answered by: rampratap409

View all questions by rampratap409   View all answers by rampratap409

Member Since Sep-2006 | Answered On : Dec 7th, 2006

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

Showing Answers 1 - 4 of 4 Answers
Scott

Answered On : May 25th, 2005

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.

  
Login to rate this answer.
Pankaj & Sunil

Answered On : Sep 10th, 2005

Union Will eliminate duplicate rows from both the tables which are participating in the union operation

  
Login to rate this answer.
Atal

Answered On : Sep 16th, 2005

View all answers by Atal

UNION: Take the common record once( No Duplicate)UNION ALL : Takes Duplicates alsoExampl : Say there is EMP having 14 reconds then...select count(1) from (select ename from emp)  returns 14select 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. 

  
Login to rate this answer.

UNION: Take the common record once( No Duplicate)UNION ALL : Takes Duplicates alsoMinus:  Result of first query - result of second queryexamleselect * from emp where rownum<=9;minusselect * from emp where rownum<9;this will display 9th row of empIntersect:  common result of both query

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.