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 email, and the number of orders.
Write a select statement that returns one r $ w for each customerid showing the customer's ID email address, and COUNT of ORDERID You will need to join two tables, OECUSTOMERS and OEORDERS. Use a LEFT JOIN. Do NOT use a natural join.
Grouping by CUSTOMERID you will need to show the following columns:
The CUSTOMERID column from the OECUSTOMERS table.
The CUSTEMAIL column from the OECUSTOMERS table
The COUNT of ORDERID from the OEORDERS table with an alias of NUMORDERS
Sort the result set in ascending order by the CUSTOMERID field
If you use a left join, you may get an "ORA: column ambiguously defined" error. This is because the CUSTOMERID is in both the OECUSTOMERS and OEORDERS table. You will need to either use a natural join or explicitly pick one, eg OECUSTOMERS.CUSTOMERID
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
