D yes but A no!
The reason why B is wrong is Illustrated here: in case of two compound Statements : The number and the order of columns must be the same in the two queries.
https://www.oracletutorial.com/oracle-basics/oracle-intersect/
The number has to be the same but the names can be different. In that page you linked, in fact, I see no reference to the fact that the names must be the same, even though they are in the example.
The correct answers are:
D. INTERSECT returns rows common to both sides of the compound query
E. INTERSECT ignores NULLs
Explanation:
D. INTERSECT returns rows common to both sides of the compound query:
The INTERSECT operator returns only the rows that are present in both queries (i.e., rows common to both result sets). If a row exists in one query's result but not the other, it will not appear in the INTERSECT result.
E. INTERSECT ignores NULLs:
INTERSECT treats NULL values as equal when comparing rows, which means if two rows contain NULL in the same position, they are considered identical for the purpose of intersection. However, NULL values do not affect whether a row is included in the result set as long as the rows are otherwise identical.
A - TRUE; Release 19, SQL Language Reference, 9 SQL Queries and Subqueries, The UNION [ALL], INTERSECT, MINUS Operators; The corresponding expressions in the select lists of the component queries of a compound query must match in number and must be in the same data type group (such as numeric or character). => column names can be different, important is a datatype
B - FALSE; see A, there's a mention: The corresponding expressions in the select lists of the component queries of a compound query must match in number ...
C - FALSE; Release 19, SQL Language Reference, 4 Operators, Set Operators; All distinct rows selected by both queries => order is not important
D - TRUE; see C
E - FALSE; https://blog.jooq.org/how-to-use-sql-intersect-to-work-around-sqls-null-logic/ Like UNION or EXCEPT (MINUS) in Oracle, as well as SELECT DISTINCT, these set operations handle two NULL values as NOT DISTINCT. Yes, they’re not equal but also not distinct.
-> example tables t1 and t2 in 19.3.
SQL> select * from t1 /*rows: 1,2,3,null*/;
N
----------
1
2
3
4 rows selected.
SQL> select * from t2 /*rows: 2,null*/;
NN
----------
2
2 rows selected.
--> Test A, D and E.
SQL> select n from t1
2 intersect
3 select nn from t2;
N
----------
2
2 rows selected.
--> Test B
SQL> select n, n from t1
2 intersect
3 select nn from t2;
select n, n from t1
*
ERROR at line 1:
ORA-01789: query block has incorrect number of result columns
--> Test C
SQL> select nn from t2
2 intersect
3 select n from t1;
NN
----------
2
2 rows selected.
Summary:
A. Column names in each SELECT in the compound query can be different --> True
B. The number of columns in each SELECT in the compound query can be different --> False
C. Reversing the order of the intersected tables can sometimes affect the output --> False
D. INTERSECT returns rows common to both sides of the compound query --> True
E. INTERSECT ignores NULLs --> False
A is correct. Column names in a compound query is not important, column data types are as well as the number of columns.
B is wrong. Compound queries must have the same amount of columns in each of the query blocks.
C is wrong. Intersect shows rows that are common to both queries so the order of the query blocks do not matter.
D is correct. This is the purpose of the INTERSECT operator.
E is wrong. NULLS are processed in SET queries.
AD are correct
https://www.examtopics.com/discussions/oracle/view/8224-exam-1z0-071-topic-1-question-239-discussion/
upvoted 6 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
danito
Highly Voted 4 years, 7 months agoama
4 years, 6 months agoSimoneF
4 years agoEkos
4 years agoyou1234
Highly Voted 4 years, 6 months agoArchieVon
Most Recent 2 months agonautil2
1 year, 3 months agoauwia
1 year, 6 months agojosue1
2 years, 6 months agoFranky_T
2 years, 8 months agoryuah
3 years agoSharif1
4 years, 5 months agoNowOrNever
4 years, 5 months ago