'MY SQL INSERT and using WHERE with a mix of integers
im currently having problems with this conditions that must be met and dont really know where to insert the WHERE =< and IF NOT => statement on this code.
HERE ARE THE CONDITIONS THAT MUST BE MET BELOW
• Quantity Discount: This represents the new policy (effective January 1, 2019) that all orders 90 units and over will automatically earn a 10% discount. An order of 89 units does not earn the discount; an order of 90 units does earn the discount. All order discounts have been rounded to the nearest penny, so you can assume this field has no decimals in it. In the data below,
Order 0, on the first line, of 95 Only Pancakes to Florida, did qualify for the Quantity Discount, because an order quantity of 95 exceeded the 90 threshold. The Quantity Discount has been computed as 3924, or 10% of 39235. In this case, the final order total would be 39,235 – 3,924 = 35,311 (or $353.11).
Order 4, on the fifth line, of 31 Future Toasts to North Carolina, did not qualify for the Quantity Discount. Therefore, the Order total would simply be the Order subtotal.
and the code that I was able to right was this
INSERT INTO stagingTable
("monthInt", "state", "country", "region", "Product_Name", "unitPrice" ,"quantity",
"orderTotal")
SELECT "Month", "State", "Country", "Region", "Product", "Per-Unit_price", "Quantity",
"Order_Subtotal"-("Quantity_Discount"+"per-unit_price"*"Quantity")
FROM pd2019;
UPDATE stagingTable SET yearInt=2019 WHERE yearInt ISNULL;
my question is
what would be the appropriate code to produce the final data that is on the quantity discount? because it has certain conditions that is included to produce the proper output or data on the table. btw im actually merging 3 data tables into one.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
