solved SQL Assignment 1Purpose: To provide you an opportunity to apply
SQL Assignment 1Purpose: To provide you an opportunity to apply (SQL) in the data processing cycle.Database : Northwind_original (on Canvas)Tools: SQLiteStudio (See Instruction for Downloading SQLiteStudio on Canvas). undefinedBefore starting the assignment, install SQLiteStudio on your computer and download the above database in your computer. To be submitted:Submit each SQL assignment in ONE file. The file should include everything required to be submitted for that assignment.SQL query statements (21 statements)Screenshots of partial output for questions that require screenshots of output (total 4 screenshots, 8 points). I also recommend copying and pasting your SQL statements into a word or notepad file and saving the file in multiple places (e.g., on a computer, email, cloud, external hard drive, etc.).If you have already experienced losing your hard work at some point then you know how important having a backup is…at all times.Note that you should execute (run) the query for each question only once and do not need to store your queries in SQLiteStudio.undefinedTo complete these exercises, you need to consult the textbook (chapter 4) and online help https://www.w3schools.com/sql/.Keywords are included in the assignment to help you locate the related online help for each exercise.When the questions for this assignment do not specify which rows to show in the results, assume that all rows should be shown.Similarly, when the questions do not specify which columns to show in the results, assume that all columns should be shown.When the questions specify that only certain columns should be included in the results, this does not imply that other columns cannot be used in the query (they should simply not be part of the output).SQL #1 QuestionSelect specific rows: ALIASES and CASE.Create new columns (fields) in the results.Create VIEWS. GROUP and AGGREGATE (e.g., COUNT, AVG, SUM):1-Select all data in a table:-Use the OrderDetails table and create a query that displays all the data in this table.2-Select specific columns: -Use the OrderDetails table and create a query that displays ProductID and Quantity only.3-Select specific rows:3.1) WHERE. Use the OrderDetails table and create a query that displays order line items: a) with OrderID 10251. b) that are not for product 38. c) with unit prices more than $50 and quantity more than 25. d) with quantity more than 100 or unit price more than 200. 3.2) WHERE. Use the OrderHeaders table and create a query that displays all orders (rows): a) placed in 2019 (you can assume that there is no later orders). b) that were shipped after they were required. c) that have not yet been shipped (Hint: statement “shipped date is nullâ€).3.3) DISTINCT.Use the OrderDetails table and create a query that displays: a) all unique products sold (only show Product IDs in the results). b) all unique products sold with a unit price of more than $50.3.4) ORDER BY. Use the products table and create a query that shows: a) products sorted by UnitsInStock in descending order.3.5) LIKE and WILDCARDS.Use the Customers table and create a query that shows all customers with: a) “manager” in the ContactTitle. b) company names that start with F. 4-ALIASES and CASE.Create new columns (fields) in the results.Note that aliases are temporary…and not stored for reuse in a query.a) Use the Products table and create a query that shows Product Name, Units In Stock, Units On Order, Reorder Level, and a calculated field named Units Available defined as Units In Stock + Units On Order. b) Use the Products table and create a query that shows Product Name, Units In Stock, Units On Order, Reorder Level, the calculated field Units Available (copy and paste the query you created in 4a), and a new calculated field named Reorder Needed that displays “Yes†if UnitsAvailable < ReorderLevel and otherwise “Noâ€. 5- Create VIEWS. Note that views are virtual tables.If you need to troubleshoot a view at some point you can simply delete it and recreate it. a)Copy and paste the query in 4a and create a view called ProductAvailability based on this query. b.Using the ProductAvailability view that you created in 5a, create a query that only shows products that need to be ordered (that have UnitsAvailable less than the ReorderLevel).6-GROUP and AGGREGATE (e.g., COUNT, AVG, SUM):a) Using the Products table, create a query that shows for each supplier:the SupplierID and the number of products associated with the supplier (name this field NumberOfItems). b) Using the OrderDetails table, create a query that shows for each order the OrderID and the total quantity sold (name this field TotalQuantity).c) Using the OrderDetails table show for each product:(i) the ProductID, (ii) the average sales unit price (name this field AverageUnitPrice; you can simply calculate the average for each product across the different order detail rows and you do not need to adjust the average for the quantity sold in each order), (iii) the total quantity sold (name this field SumOfQuantitySold), and (iv) the number of times it has been sold (name this field NumberOfSales; you can simply calculate the number of sales orders). 7-INNER JOIN:a) Using the OrderHeaders and OrderDetails tables, show OrderID, OrderDate (from the OrderHeaders table), ProductID, and Quantity (from the orderdetails). You can assume that all OrderHeaders have OrderDetails and that all OrderDetails have OrderHeaders. b) Copy and paste query 1.a and only show orders placed in 2019. 8-INNER JOIN, WHERE, GROUP, and HAVING: a) Copy and paste query 1.b, but only show one record for each ProductID. For each product show a new calculated field named SumOfQuantitySoldIn2019 defined as the total quantity sold in 2019. Store this query as a view called ProductSales2019. b) Copy and paste query 1.b, but only show products with SumOfQuantitySoldIn2019 greater than 100. c) Create the same output you did in 2.b, but use the ProductSales2019 view (that you created in 2.a) instead of the OrderHeaders and OrderDetails tables.9- LEFT JOIN (same as LEFT OUTER JOIN):a) Using the Products table and ProductSales2019 view, show for all products, the quantity sold in 2019.Display the (i) ProductID and (ii) ProductName for all products in the Products table, and (iii) SumOfQuantitySoldIn2019 (include null values for products not sold in 2019). 10-INNER JOINS: Join three tablesUsing the OrderDetails, OrderHeaders, and Products tables, determine for each product the average price received in 2019 and compare this amount to the list price (the unit price in the Products table).In your output display (i) ProductID, (ii) AveragePriceReceived (i.e., average sales unit price in 2019 for each product where sales unit price is UnitPrice*(1-Discount) from the OrderDetails table), (iii) UnitPrice from the products table, and (iv) a new calculated field that calculates the percentage difference between AveragePriceReceived and the UnitPrice in the products table.Name this field PercentPriceDifference.