Exercise 2
Create a Database named
northwind.Download the SQL file from this link and run the code present in it inside the
northwinddatabase. (Make sure that the tables are created insidenorthwinddatabase only)Write an SQL query to display the
ProductID,ProductName,UnitPricefromProductstable in decreasing order of theUnitPrice.Write an SQL query to display all the distinct
CategoryNameinCategoriestable.Write an SQL query to count the total number of unique
OrderIdinOrder Detailstable.Write an SQL query to display the
OrderID,Employee Full Name(example: Mr. John Doe),Customer Company NameandOrderDatein such a way that the Latest Order is displayed at the top.Write an SQL query to display the most expensive
UnitPriceinProductstable for eachCategoryName. Also, arrange it in ascending order ofCategoryName.Write an SQL query to display the
OrderID,CustomerName,OrderDateand thetotal sales amountfor each OrderId and Customer. (Total Sales Amount = (Quantity * UnitPrice) - ((Quantity * UnitPrice) * Discount)Write an SQL query to display the
CustomerNameand thetotal sales amountfor each OrderId and Customer. (Total Sales Amount = (Quantity * UnitPrice) - ((Quantity * UnitPrice) * Discount)Write an SQL query to display the
SupplierNameand thetotal sales amountfor each Supplier. (Total Sales Amount = (Quantity * UnitPrice) - ((Quantity * UnitPrice) * Discount)Write an SQL query to display the
ShipperNameand theTotal number of ordersplaced for each Shipper.Write an SQL query to display the
CustomerNameand theTotal number of ordersplaced for each Customer.Write an SQL query to display the
ProductNameand theTotal number of ordersplaced for each Product.Write an SQL query to display the
ProductNamethat has the most number of Orders Placed.Write an SQL query to display the total Discount given out.
Write an SQL query to display
OrderId,CustomerName,OrderDate,OrderMonthandOrderYearin increasing order of OrderDate. (Hint: use date time functions in SQL)Write an SQL query to display
Total Sales including discountsfor eachMonthandYear.Write an SQL query to find the
monthwith the mostnumber of ordersplaced.Write an SQL query to find the
yearwith the mostnumber of ordersplaced.Write an SQL query to display the
TotalSalesfor eachyear.
Last updated
Was this helpful?