Question: SQL with Multiple Tables **You need to only submit the SQL statement for each problem. These queries use the CUSTOMER-PRODUCT-AGENTS-SALE tables. CUSTOMER(Cid, cname, city, discount)

SQL with Multiple Tables

**You need to only submit the SQL statement for each problem.

These queries use the CUSTOMER-PRODUCT-AGENTS-SALE tables.

CUSTOMER(Cid, cname, city, discount)

AGENT(Aid, aname, city, commission)

PRODUCT(Pid, pname, city, qtyOnHand, price)

SALE(SaleNo, SaleMonth, Cid, Aid, Pid, quantity, totalAmt)

You are only required to submit the SQL statement. You may use Oracle 11g or Access.

1) List the name of all products that were sold.

2) List the name of each customer that bought something and the product name for each product they bought.

3) List the name of customers that bought product p07

4) List the name of customers that bought pencils this is bit harder it requires 2 joins.

5) List name of agents that placed a sales order for customer c002 or customer c003

6) List name of agents that placed a sale for customers Allied or Basics this is bit harder it requires 2 joins. YOU CANNOT do a comparison with cid you must compare with the customer name.

7) List the agent name, product name and customer name for each product ordered.

8) List name of customers that bought product p03 through agent 'a06'

9) List name of customers that bought staplers through agent Smith this is bit harder it requires 3 joins. YOU CANNOT do a comparison with pid or aid you must use the product name and the agent name.

10) List the name of each customer that bought something, the pid of what they bought and also the customers that did not buy anything.

11) What was the total amount sold for each product you must list the product name.

12) List the name of each customer and the sum of the total amount bought by the customers and also list the customers that did not buy anything.

13) List the name and the sum of total amount for each customer that bought more than $2,000 worth of merchandise

14) In words, explain the result of the following SQL Statement:

SELECT * from CUSTOMERS, PRODUCTS

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!