Exercise 2
Create a Database named
northwind
.Download the SQL file from this link and run the code present in it inside the
northwind
database. (Make sure that the tables are created insidenorthwind
database only)Write an SQL query to display the
ProductID
,ProductName
,UnitPrice
fromProducts
table in decreasing order of theUnitPrice
.Write an SQL query to display all the distinct
CategoryName
inCategories
table.Write an SQL query to count the total number of unique
OrderId
inOrder Details
table.Write an SQL query to display the
OrderID
,Employee Full Name
(example: Mr. John Doe),Customer Company Name
andOrderDate
in such a way that the Latest Order is displayed at the top.Write an SQL query to display the most expensive
UnitPrice
inProducts
table for eachCategoryName
. Also, arrange it in ascending order ofCategoryName
.Write an SQL query to display the
OrderID
,CustomerName
,OrderDate
and thetotal sales amount
for each OrderId and Customer. (Total Sales Amount = (Quantity * UnitPrice) - ((Quantity * UnitPrice) * Discount)Write an SQL query to display the
CustomerName
and thetotal sales amount
for each OrderId and Customer. (Total Sales Amount = (Quantity * UnitPrice) - ((Quantity * UnitPrice) * Discount)Write an SQL query to display the
SupplierName
and thetotal sales amount
for each Supplier. (Total Sales Amount = (Quantity * UnitPrice) - ((Quantity * UnitPrice) * Discount)Write an SQL query to display the
ShipperName
and theTotal number of orders
placed for each Shipper.Write an SQL query to display the
CustomerName
and theTotal number of orders
placed for each Customer.Write an SQL query to display the
ProductName
and theTotal number of orders
placed for each Product.Write an SQL query to display the
ProductName
that 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
,OrderMonth
andOrderYear
in increasing order of OrderDate. (Hint: use date time functions in SQL)Write an SQL query to display
Total Sales including discounts
for eachMonth
andYear
.Write an SQL query to find the
month
with the mostnumber of orders
placed.Write an SQL query to find the
year
with the mostnumber of orders
placed.Write an SQL query to display the
TotalSales
for eachyear
.
Last updated