The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 327 Weeks Ago, 5 Days Ago |
| Questions Answered: | 12843 |
| Tutorials Posted: | 12834 |
MBA, Ph.D in Management
Harvard university
Feb-1997 - Aug-2003
Professor
Strayer University
Jan-2007 - Present
How to create four queries with CASE, SET, and Declare logic using SQL AdventureWorks2014 database.
Â
I wrote the following IF THEN statement, which has a syntax error.
Â
USE AdventureWorks2014
 SELECT CASE if TotalCount >10 THEN 'TRUE' ELSE 'FALSE' END FROM
(
SELECT Style, COUNT(*) TotalCount
FROM Production.Product
)
Â
practice writing CASE, SET, and DECLARE statements.The marketing department wants to promote sales of the Road-650 bicycle. It hasdeveloped a request list related to the promotion, and you have been tasked withdetermining questions related to the Road-650 bicycle inventory.1.The marketing department wants to know if the Road-650 bicycle has more than 10styles currently available. Using the Product table, create a statement using IFTHEN logic to trigger on whether there are more or less than 10 of Road-650bicycle units available. Submit the statement and the result of the query.2.The marketing department has decided that it will only feature black colored Road-650 bicycles in the sales promotion. However, the marketing department may wantto modify the sale at a later date. Use a DECLARE and SET statement to pre-set avariable color to "Black." Using the variable, run a query to show all the type ofbicycles including all ±elds.3.Building on the question 2 activity, add the "Quantity" and "ListPrice." Filter theresults to only items in "Finished Goods Storage."4.Building on the question 3 activity, the marketing department has decided that anyproducts that currently have more than 100 units in stock will be discounted by10%. All other products will have a 5% discount as part of the promotion. Create aCASE statement that modi±es the "ListPrice" into a new ±eld called "SalesPrice."
-----------