Question: database management 2 1. (15) Write a script that uses three variables to store (1) the count of distinct orders made in the Orders table
1. (15) Write a script that uses three variables to store (1) the count of distinct orders made in the Orders table (2) the total amount of sales sales means the price of the item with discount multiplied by the quantity) made in the Orderitems table and (3) the average sales calculated using the first two variables ($909.57). Don't include TaxAmount or shipping costs. 2. (15) Write a script that uses two variables to store (1) the count of all of the products in the Products table and (2) the average list price for all products in the Products table. If the product count is greater than or equal to 7. the script should print a message that displays the values of both variables. Otherwise, the script should print a message that says, "The number of products is less than 7. 3.(25) Write a script that finds (1) The name of the customer who made the largest order (amount of money spent on a single order) and (2) the value of that largest order. Store the name and the value of the order in two different variables and then print using the two variables. A sample print statement with the correct customer and order value-The largest order of S2799.95 was made by David Goldstein Hint: This problem may require you to rese a table variable to store information that you will use to get to the required information You may need to use multiple queries. There are multiple ways to solve this problem 4. (10) Write a script that attempts to insert a new category named "Guitars" into the Categories table. If the insert is successful, the script should display this message SUCCESS. Record was inserted. If the update is unsuccessful, the script should display a message something like this: FAILURE: Record was not inserted. Error 2627: Violation of UNIQUE KEY constraint "UQ_Categori_8517B2E0A87CE853". Cannot insert duplicate key in object 'dho Categories. The duplicate key value is (Guitars) Stored Procedure 5. (10) Write a stored procedure named findAverage Sales. The procedure does not have any parameter variable (accepts no arguments) but returns the average sales value using an output parameter. You can use the code from exercise I to write the code inside the procedure (5) Code an EXEC statement to call test this procedure and print the return value. 6. (10) Write a stored procedure named spinsertCategory. The procedurc has one parameter variable (accepts one argument). which is the name of the new category that you want to insert in the Categories table and returns nothing. If the insert is successful, the procedure should print that the insert was successful. If the insert was not successful, the procedure should print that the insert failed (5) Code one EXEC statement that calls tests this procedure with a valid category name. (5) Code another EXEC statement that calls tests this procedure with an invalid category name. Note that this table doesn't allow duplicate category names
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
