Which two SQL statements would give the same output?

View the Exhibits and examine the structures of the PRODUCTS and SALES tables.
Which two SQL statements would give the same output? (Choose two.)

View the Exhibits and examine the structures of the PRODUCTS and SALES tables.
Which two SQL statements would give the same output? (Choose two.)

A.
SELECT prod_id FROM products
INTERSECT
SELECT prod_id FROM sales;

B.
SELECT prod_id FROM products
MINUS
SELECT prod_id FROM sales;

C.
SELECT DISTINCT p.prod_id
FROM products p JOIN sales s
ON p.prod_id=s.prod_id;

D.
SELECT DISTINCT p.prod_id
FROM products p JOIN sales s
ON p.prod_id <> s.prod_id;



Leave a Reply 4

Your email address will not be published. Required fields are marked *


Eamon

Eamon

The A and C combination is correct.

However I also think that the combination of B and D is also correct
as they both represent
products that were not sold
or products in the products table that don’t exist in the sales table
Suggestions!!

John

John

with t1 as(
select 1 as cust_id from dual union all
select 2 from dual union all
select 3 from dual union all
select 3 from dual
),
t2 as (
select 3 as cust_id from dual union all
select 4 from dual union all
select 5 from dual
)
select * from t1 minus select * from t2;

Try these two queries and you will know why B and D is not the correct answer.

with t1 as(
select 1 as cust_id from dual union all
select 2 from dual union all
select 3 from dual union all
select 3 from dual
),
t2 as (
select 3 as cust_id from dual union all
select 4 from dual union all
select 5 from dual
)
select distinct t1.cust_id from t1 join t2 on t1.cust_id!=t2.cust_id;

karthiga

karthiga

I am also wondering the same…