Question: Your supervisor has asked you to write a report showing how many orders each customer has made. They are requesting that you show the customer

Your supervisor has asked you to write a report showing how many orders each customer has made. They are requesting that you show the customer ID, e-mail, and the number of orders.
Write a select statement that returns one r ?bar($) w for each customer_id showing the customer's ID, email address, and COUNT of ORDER_ID. You will need to join two tables, OE.CUSTOMERS and OE.ORDERS. Use a LEFT JOIN. Do NOT use a natural join.
Grouping by CUSTOMER_ID, you will need to show the following columns:
The CUSTOMER_ID column from the OE.CUSTOMERS table.
The CUST_EMAIL column from the OE.CUSTOMERS table
The COUNT of ORDER_ID from the OE.ORDERS table with an alias of NUM_ORDERS
Sort the result set in ascending order by the CUSTOMER_ID field
If you use a left join, you may get an "ORA-00918: column ambiguously defined" error. This is because the CUSTOMER_ID is in both the OE.CUSTOMERS and OE.ORDERS table. You will need to either use a natural join or explicitly pick one, e.g. OE.CUSTOMERS.CUSTOMER_ID.
 Your supervisor has asked you to write a report showing how

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!