Question: For this activity, we will using the AdventureWorks database. (Here is the link to download the sample database if needed. https://archive.codeplex.com/?p=msftdbprodsamples Select the oltp file)
For this activity, we will using the AdventureWorks database.
(Here is the link to download the sample database if needed. https://archive.codeplex.com/?p=msftdbprodsamples
Select the oltp file)
--Query 1--Which state has the most online orders?--List the state name and how many online orders for the state with the most-- online orders.
--Query 2--Which vendors have a credit rating greater than 3?--Display the vendor name, credit rating and address (street address,-- city, state) for vendors that have a credit rating higher than 3.-- Sort the list by vendor name.
--Query 3--Who is the most senior employee in each department?--List the employee who first started working in each department. Use the-- start date in the Department to determine who started in the department-- first. Only include employees that are still working for the company.-- Include first and last name of employee, name of department, and date-- started in department.-- If there is more than one employee that started in a department on the-- earliest startdate, list them both. Order the list in alphabetical order-- by department.
--Query 4--Use PIVOT to complete this query.--What are the average sales for in-store and online purchases for each-- day of the week?--Display the name of the day, the average sales subtotal for online orders,-- and average sales subtotal for in-store orders for each day of the week-- (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday). The days-- of the week are to be the headers across the top and 0 and 1 for in-store-- and online for the rows.-- You can use a CASE statement to replace the o and 1 for In Store and-- Online. This is not required. It is just if you are interested.
--Query 5--Use PIVOT to complete this query.--How many units are sold each month for each category?--List each category name, year, and the number of units sold by month. The-- names of the months are to be headers across the top and category names-- and years down the rows. Order by category name first and then year.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
