Question: Help with SQL errors This is schema and I'm having some errors getting result A manager wants to know the email address, number or orders,

Help with SQL errors

This is schema and I'm having some errors getting result

Help with SQL errors This is schema and I'm having some errors

A manager wants to know the email address, number or orders, and the total amount of purchases made by each customer. Create a summary query that returns these three items for each customer that has orders. Hint: The total is the price minus the discount, multiplied by the quantity

==========================================================

select cust.EmailAddress, count(orde.OrderID) as "Total Orders",((ordi.Itemprice-ordi.DiscountAmount)*ordi.Quantity) as "Total Purchase Amount"

from Customers cust

join Orders orde on cust.CustomerID = orde.CustomerID

join OrderItems ordi on orde.CustomerID = ordi.OrderID

Group by cust.EmailAddress

Having count(orde.OrderID)>0

===================================================

Column 'OrderItems.ItemPrice' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

Column 'OrderItems.DiscountAmount' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

Column 'OrderItems.Quantity' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

Administrators AdminlD EmailAddress Password FirstName LastName Orderltems ItemID OrderID ProductiD temPrice DiscountAmount Products ProductiD CategoryID ProductName Description ListPrice DiscountPercent DateAdded Orders Addresses OrderlD CustomerlD OrderDate ShipAmount TaxAmount ShipDate ShipAddressID AddresSID CustomeriD Line1 Line2 Customers CustomerID EmailAddress Password FirstName State ZipCode ShippingAddressID BillingAddressID Categories CategoryID CategoryName CardNumber CardExpires BillingAddressID

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!