Which SET operator would you use to get the required output?

View the Exhibit and examine the structure of the CUSTOMERS and CUST_HISTORY tables.

The CUSTOMERS table contains the current location of all currently active customers. The
CUST_HISTORY table stores historical details relating to any changes in the location of all current
as well as previous customers who are no longer active with the company.

You need to find those customers who have never changed their address.
Which SET operator would you use to get the required output?

View the Exhibit and examine the structure of the CUSTOMERS and CUST_HISTORY tables.

The CUSTOMERS table contains the current location of all currently active customers. The
CUST_HISTORY table stores historical details relating to any changes in the location of all current
as well as previous customers who are no longer active with the company.

You need to find those customers who have never changed their address.
Which SET operator would you use to get the required output?

A.
INTERSECT

B.
UNION ALL

C.
MINUS

D.
UNION



Leave a Reply 13

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


crane

crane

why?’never changed their address’ ,i think is INTERSECT ,INTERSECT give the same

Bogdan

Bogdan

The INTERSECT give only the customers which are active and has at least one change (one record in HIST);
Regards;

Dipak Upwanshi

Dipak Upwanshi

Can any one tell me the query, how minus will give correct output in this condition?

Bogdan

Bogdan

You mean that the tables has different structures. You can select only CUST_ID,CUST_NAME and CUST_CITY for MINUS;
Regards

spellublind

spellublind

Table A
Customer
(It includes customer who has not changed address and customer who has changed address)


Table B
Customer
(
It includes customer who has changed address and previous customer)

Vishal

Vishal

I didn’t get this query. can someone please help

Khalid

Khalid

customers table
has records of all those customers who didn’t change their Address and they are active.

Cust_History Table
When Address of customer change/ became inactive then for history information is stored in this table

table1 Minus table2 = records of table1 not present in table2

Sagar

Sagar

Read carefully.
CUST_HISTORY table stores only those customer details when there is any change in their location. So by filtering out those customer records from CUSTOMERS table, we get the list of customers for which addresses have never been changed.

bob

bob

Correct. I interpreted CUST_HISTORY as being the ‘complete’ history of the customer (e.g. creation and changes) however it actually only has the changes.

Oscar Islas

Oscar Islas

If A and B are sets, then the relative complement of A in B, also termed the set-theoretic difference of B and A, is the set of elements in B, but not in A.

lbien

lbien

select cust_id from CUSTOMERS
minus
select cust_id from CUST_HISTORY;