MYSQL #6. Write a script that will give you six columns of output. a)the custome
ID: 672880 • Letter: M
Question
MYSQL
#6. Write a script that will give you six columns of output.
a)the customer first name
b)the customer last name
c)the order number
d)the item name
e)the discount
a column with the following words for the e)discount----either NONE, LESS THAN TWENTY, LESS THAN FORTY, or MORE THAN FORTY
Products OrderItems ProductID CategorylD ProductCode ProductName Description ListPrice DiscountPer... DateAdded ItemID OrderID ProductID ItemPrice DiscountÄm... Quantity Customers CustomerID EmailAddress Password FirstName LastName ShippingAddressID BillingAddressID Orders OrderID CustomerID OrderDatee ShipAmount TaxAmount ShipDate ShipAddressID CardType CardNumber CardExpires BillingAddressID Categories Addresses CategoryID CategoryName AddressID CustomerID ine ine City State ZipCode Phone DisabledExplanation / Answer
SELECT Customers.FirstName,
Customers.LastName,
Orders.OrderID,
Products.ProductName,
OrderItems.DiscountAmount,
IF(OrderItems.DiscountAmount = 0, 'NONE', IF(OrderItems.DiscountAmount <= 20, 'LESS THAN TWENTY', IF(OrderItems.DiscountAmount <= 40, 'LESS THAN FORTY', 'MORE THAN FORTY'))) AS discount
FROM Customers
INNER JOIN Orders ON (Customers.ShippingAddressID = Orders.ShippingAddressID AND Customers.BillingAddressID = Orders.BillingAddressID)
INNER JOIN OrderItems ON (Orders.OrderID = OrderItems.OrderID)
INNER JOIN Products ON (OrderItems.ProductID = Products.ProductID)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.