Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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 Disabled

Explanation / 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)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote