Question: Written in T-SQL using the TSQL4 database. I have the first 2 solved but written in MySQL, posted below. Please help! Q1 select sod.productid, productname,
Written in T-SQL using the TSQL4 database. I have the first 2 solved but written in MySQL, posted below. Please help!

Q1
select sod.productid, productname, sum((sod.unitprice*qty)) as total
from Production.Products pp join
Sales.OrderDetails sod on
pp.productid = sod.productid join
Sales.Orders so on
so.orderid = sod.orderid
where so.shipcountry = 'USA'
group by sod.productid, pp.productname;
Q2
Sales.Customers sc on
sc.custid = so.custid
where exists (select sod.productid from Sales.OrderDetails as sod
join Production.Products as pp on
sod.productid = pp.productid join
Production.Categories as pc on
pc.categoryid = pp.categoryid
where pc.categoryname = 'Beverages' )
GO
1. List the product ID, product name, and the total dollar amount for all items that were shipped to customers in the USA. Use a correlated query. 2. List the order ID, order date, employee ID, employee last name, customer ID, and company name for all orders that contain at least one item from the Beverages category. Use the category name in your query and use the Exists predicate 3. Write a stored procedure to do the query in problem 1, accepting the country name as a parameter. After testing the procedure, script it into a file for submission. Write a stored procedure to do the query in problem 2, accepting the category name as a parameter. After testing the procedure, script it into a file for submission. 4. 5. List the order ID, order date, customer ID, and company name for all orders that fail to contain at least one item from the Confections category 6. Write a stored procedure to solve problem 5, accepting the category name as a parameter. 1. List the product ID, product name, and the total dollar amount for all items that were shipped to customers in the USA. Use a correlated query. 2. List the order ID, order date, employee ID, employee last name, customer ID, and company name for all orders that contain at least one item from the Beverages category. Use the category name in your query and use the Exists predicate 3. Write a stored procedure to do the query in problem 1, accepting the country name as a parameter. After testing the procedure, script it into a file for submission. Write a stored procedure to do the query in problem 2, accepting the category name as a parameter. After testing the procedure, script it into a file for submission. 4. 5. List the order ID, order date, customer ID, and company name for all orders that fail to contain at least one item from the Confections category 6. Write a stored procedure to solve problem 5, accepting the category name as a parameter
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
