Write a select statement that will display customer number, customer name and th
ID: 3910837 • Letter: W
Question
Write a select statement that will display customer number, customer name and the number of orders belong to the customer whose state is California. You will need to join two tables, use a COUNT aggregate and a GROUP BY clause in your SELECT statement. Override labels with a more descriptive but brief label
Can you please post this in the Oracle DBMS command? All the other questions like this on Chegg, the answers are not working.
reply: I'm not sure if this is what your looking for, its almost identicle to this:
SELECT cust_number, cust_name, count(ord_number) as number_of_orders,
FROM MSC_Customer, MSC_Order
WHERE
MSC_Customer.cust_number=MSC_Order.cust_number
GROUP BY cust_number
HAVING cust_city like "CA"
however its not working. Maybe its a little too advanced for the system I am on...I dont know.
Explanation / Answer
Answer)
As I understand, you need to join two tables using a COUNT aggregate and a GROUP BY clause in your SELECT statement.
You are provided with the above query in the question which is not working for you.
I am going to modify the query for you.
SELECT MSC_Customer.cust_number, MSC_Customer.cust_name, count(MSC_Order.ord_number) as number_of_orders
FROM MSC_Customer inner join MSC_Order
on
MSC_Customer.cust_number=MSC_Order.cust_number
GROUP BY MSC_Customer.cust_number
HAVING MSC_Customer.cust_city like "CA%";
Please execute the query and share the feedback.
Thanks a lot for posting.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.