Assignment: Skill Assessment: SQL
Assignment: Skill Assessment: SQL
1. In this exercise, you will review the steps you completed during the CFI videos.
2. Connect to the server you used in the CFI course SQL Fundamentals.
3. In this exercise, we will be working with the table FactResellerSales.
4. Extract sales order number, amount of sales, discount, order quantity; and total product cost,
aggregating them by the order (which should be renamed as the InvoiceNumber).
5. Other variables should be renamed as TotalInvoice, TotalDiscount, QuantitySold, and SalesCost,
respectively.
6. Round all your numbers to two digits after the decimal in your query
7. Limit your sample to include only sales in Australia and over $2500. How many observations are
extracted?
8. Create a new column that will identify sold quantities above 100 as "Top Sales. " Hint: Use an IIF
statement.
9. Finally, extract top-5 invoices by quantity sold. Add the resulting table to a Word Document - no
screenshots are allowed.
10. Now, append the data from the Internet Sales table. However, make sure that the query returns
an indicator specifying the source of an invoice: Online or Reseller.
11. Finally, calculate the average discount received online and the average discount received through
a reseller.
Submission guidelines
You will submit a Word document explaining the steps undertaken in your
query,accompanied with the relevant answers to the questions.
Query(s) files.
table FactResellerSales
Extract sales order number, amount of sales, discount, order quantity; and total product cost, aggregating
them by the order (which should be renamed as the InvoiceNumber).
SELECT
CustomerKey AS CustomerID,
SUM(SalesAmount) AS SalesAmount
FROM FactInternetSales
GROUP BY CustomerKey
https://www.chegg.com/homework-help/questions-and-answers/16-create-query-produce-total-
purchase-per-invoice-generating-results-shown-figure-p716-so-q126318285?fromSearch=true&search=
%3Cdiv%3E%3Cp%3E2.%20In%20this%20exercise%2C%20we%20will%20be%20working%20with%20the
%20table%20FactResellerSales.%0A3.%20Extract%20sales%20order%20number%2C%20amount%20of
%20sales%2C%20discount%2C%20order%20quantity%3B%20and%20total%20product%20cost%2C
%20aggregating%20them%20by%20the%20order%20(which%20should%20be%20renamed%20as
%20the%20InvoiceNumber).%3C%2Fp%3E%3C%2Fdiv%3E&searchid=452501d7-7615-460a-bbd7-
abaa80a2b9a7&strackid=0d626e5458b9&trackid=a3cb4451eeb6&resultrank=1&searchscore=0.6603034
Category Sales for 1997, all quarters, totals greater than $100000 only:
Category Sales for 1997, first quarter only, totals greater than $20000:
Average freight by shipper greater than $75 (for all freight charges):
or perhaps
Same query as previous (repeated products) as created by the Find Duplicates wizard (ORDER BY
clause added separately):
SELECT First([Order Details].ProductID) AS [ProductID Field], Count([Order Details].ProductID) AS
NumberOfDups
FROM [Order Details]
GROUP BY [Order Details].ProductID
HAVING (((Count([Order Details].ProductID))>1))
ORDER BY Count(ProductID) DESC;
Same query as previous (repeat product and price) using the Find Duplicates wizard:
SELECT ProductName,UnitPrice
FROM Products
WHERE UnitPrice <
(SELECT AVG(UnitPrice) From Products)
ORDER BY UnitPrice DESC;
SELECT CompanyName
FROM Suppliers AS s
WHERE NOT EXISTS
(SELECT *
FROM Products p, Categories c
WHERE p.SupplierID = s.SupplierID
AND p.CategoryID = c.CategoryID
AND CategoryName LIKE "*Dairy*");