Answered step by step
Verified Expert Solution
Question
1 Approved Answer
To measure your competency with the topics covered in the previous 3 lessons, let's work through a 5 - part challenge that brings all of
To measure your competency with the topics covered in the previous lessons, let's work through a part challenge that brings all of the concepts together.
In this challenge, we will utilize the retail.products table. Complete each part in order as they progressively build on each other.
You will see a column called sku in the retail.products table. This is retail jargon for a product code or internal name for a product. In different lessons or exercises, the field will sometimes be called productcode, but know that the two fields are equivalent.
To see the Task's Checks, Feedback, Expected and Actual Results, you may have to enlarge your results window. To see the Hints, you may have to condense the Task.
Task #: Pull all of the products that are currently on markdown.
In your results, include:
productid
sku
originalprice
currentprice
onmarkdown
Want a hint?
If a product is currently on markdown, there will be a for that product in the onmarkdown column.
For each of the next parts of this Challenge, add a new column onto your query from Step
Task #: Pull the dollar amount that is being discounted for each of the products that are currently on markdown. Add this new column onto the end of your results and call it discountamount.
Want a hint?
This part is a bit tricky so take your time and really think over the solution. Use the hints if you need to
Task #: Calculate what percentage of the originalprice the discountamount is Remember to add this calculation to the end of your query as another column and name it discountpct
Make sure that the result is less than and contains decimal places.
Want a hint?
Use the ROUND function to make sure your new column has only decimal places. Refer back to the Working with Decimals portion of the Math with SQL lesson if you need a refresher on how to use the ROUND function.
You will need to multiply one field in your calculation by otherwise a calculation of all integers will result in an integer. To calculate a percentage, take the calculation from your discountamount column and divide it by the originalamount Be careful of your parentheses!
Want another hint?
You cannot reference a calculated column name like discountamount in the same query. Copy the calculation from the previous step.
Task #: Now that you have the discountpct use your code from that calculation and multiply it by the originalprice to see if it matches the discountamount you calculated Again, do this calculation in a new column and name the column check.
Want a hint?
Task #: Determine what the sale price would be for each item if the Marketing team went off the rails and implemented a sale for off the original price of all items!
Once again, add this new column onto the end of your existing query and name it discount
Want a hint?
There are a couple different ways to get the right number for this last column.
You can either multiply the necessary field by which is
Or you can multiply the necessary field by and subtract that from Either way should work!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started