Suppose we are working with two tables defined as follows: SALESREP(SalesRepNo, RepName, HireDate) and CUSTOMER(CustNo, CustName, Balance, SalesRepNo). Which of the following ANSI SQL queries would return only the name of the sales representative and the name of the customer for each customer that has a balance greater than 400?a. SELECT *
FROM SALESREP, CUSTOMER
WHERE Balance > 400;
b. SELECT DISTINCT RepName, CustName
FROM SALESREP, CUSTOMER
WHERE Balance > 400;
c. SELECT *
FROM SALESREP, CUSTOMER
WHERE SALESREP.SalesRepNo = CUSTOMER.SalesRepNo
AND Balance > 400;
d. SELECT RepName, CustName
FROM SALESREP, CUSTOMER
WHERE SALESREP.SalesRepNo = CUSTOMER.SalesRepNo
AND Balance > 400;
e. SELECT RepName, CustName
FROM SALESREP, CUSTOMER
WHERE Balance > 400
GROUP BY SalesRepNo;

Respuesta :

Answer:

D. is the answer.

Explanation:

Since we need sales representative name and customer name, we should select only those columns.

Also we need to join the two tables with the common column i.e. "SalesRepNo", to get only the sales reps that have a sale and their corresponding cutomer(s).

Finally, we need to check for customer balance > 400 condition.

Q&A Education