127k views
0 votes
The CUSTOMERS and SALES tables contain these columns:

CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total sales?
a.SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
b.SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
c.SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
d.SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);

User Sigvardsen
by
8.1k points

1 Answer

0 votes

Final answer:

The correct SELECT statement to fetch the customer ID, company, and total sales is option a, which properly joins the CUSTOMERS and SALES tables on their CUST_ID fields.

Step-by-step explanation:

The correct SELECT statement to return the customer ID, the company, and the total sales, based on the given columns in the CUSTOMERS and SALES tables, would be:

a. SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;

This query utilizes table aliases 'c' for CUSTOMERS and 's' for SALES, and correctly matches the CUST_ID fields from both tables to ensure that the data returned is associated with the same customer. This SQL statement specifies the joining condition in the WHERE clause, allowing for the appropriate rows from both tables to be combined and displayed in the result set.

User Jason C
by
8.2k points