Question
Write the SQL queries using the database defined. -- Use Northwind Database /* 1. For each product list its name, unit price, and how many
Write the SQL queries using the database defined.
-- Use Northwind Database /* 1. For each product list its name, unit price, and how many units we have in stock. */
/* 2.List the product name and units in stock for any product that has a units in stock greater than 10 and less than 50. */
/* 3.List the product name, unit price for each product with a unit price greater than $100. Sort the list with the largest unit price on top. */
/*4. Create a list of products that should be re-ordered (Note: the products should not be discontinued (discontinued: 1=True; 0=False and total on hand and products on order should be less than the reorder level. */
/* 5.Create a list of products that have been discontinued */
/* 6. Create a list of all the products (prod_id and name) if all the following are true (7 records) Supplierid = 2, 5, 16, 8, or 9 Categoryid = 1, 2, or 4 Unitprice > 15.00 */
/* 7. Create a list of all the products (prod_id and name) if all the following are true (11 records)
Supplierid = 2, 5, 16, 8, or 9 AND Categoryid = 1, 2, or 4 AND Unitprice > 15.00 OR Supplierid = 1, 4, 8 AND categoryid= 3 or 4 */
/* 8. Create a list of product names that have the second letter of the name = h (8 records) */
/* 9. Create a list of product names that have the second letter of the name = a and the last letter = e (2 records) */
/* 10. List all the customers that have one of the following fields NULL (Region or Fax). Also the title of the contact should be Owner Sort the list by contact name (14 records) */
/* 11. List each employees name (first and last in one column) and their birthdate. Sort the list by birthdate. */
/* 12. Which employees were born in 1963? */
/* 13. How many employees does Northwind have? */
/*14. For each customer (customer id) list the date of the first order they placed and the date of the last order they placed. */
/* 15. Using question 14, only list customers where there last order was in 2011. Sort the list by customer. */
/* 16. Which employees were born in the month of July? */
/* 17. How many orders has Northwind taken? (Answer 830) */
/* 18. How many orders were placed per year? */
/* 19. How many orders by month for each year? Make sure the list is in order by year and month? */
/* 20. Using question 19, list only the months where Northwind have less than 25 orders. (3 records) */
/* 21. For each order detail, list the ordered, productid, and the total sale price */
/* 22. List the total amount of sales for all orders.*/
/* 23. For each order detail, list the orderid, productid, and the total sale price (include the discount). HINT: If my quantity was 10, each one cost $20 and had a discount of 10%, my formula may appear as (10*(20*(1 -.10)) result would be 180. */
/* 24. List the total amount of sales for all orders. (with discounts included). Result: 1265793.03974152 */
/* 25. How old is each employee? List the oldest at the top of the list. HINT: Can use DateDiff(interval, date1, date2) function: DATEDIFF(dd, Birthdate, SYSDATETIME())/365 AS Age */
/* 26. Create a list of suppliers (companyname, contactname) and the products (product name) they supply. Sort the list by supplier, then product (77 Records) */
/* 27. Create a list of customers (companyname) and some information about each order (orderid, orderdate, shipdate) they have placed. (830 Records) */
/* 28. Create list of products that were shipped to customers on 04/18/2012. (4 Records) */
/* 29. Create a list of customers that have ordered Tofu. Make sure to list each customer only once. (18 Records) */
/*30. Create a list of customers that have placed and order in 2011 and 2012. Sort the list by customer contact. (65 Records) */
/* 31. Create a mailing list to send information to all the customers, employees, and suppliers. Sort the list by city. (129 records) */
/* 32. Create a view called NumCustomerOrders which lists all the customers and the number of orders they have placed. Be sure to list the customer even if they have not placed an order. (91 records) */
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