HRCMEH56 - Aditya Bose - SQL Exercise - 2
HRCMEH56 - Aditya Bose - SQL Exercise - 2
Syntax
Screenshot
Syntax
SELECT ship.ShipperName
FROM Shippers as ship INNER JOIN Orders as ord ON
1
ship.ShipperID = ord.ShipperID
WHERE OrderID LIKE '10318';
Screenshot
Syntax
SELECT od.OrderID
FROM OrderDetails as od INNER JOIN Products as pd ON
od.ProductID = pd.ProductID
WHERE Unit LIKE '1 kg pkg.';
Screenshot
2
4. Display the Order date when the Customers from the
city, ‘Buenos Aires’ placed an order.
Syntax
SELECT ord.OrderDate
FROM Orders AS ord INNER JOIN Customers AS cus ON
ord.CustomerID = cus.CustomerID
WHERE City = 'Buenos Aires';
Screenshot
3
5. Display the Customer names who ordered the costliest
product.
Syntax
SELECT Cust.CustomerName
FROM Customers AS cust JOIN Orders AS ord ON
cust.CustomerID = ord.CustomerID
JOIN OrderDetails AS orddet ON ord.OrderID = orddet.OrderID
JOIN Products AS pro ON orddet.ProductID = pro.ProductID
WHERE pro.Price = (SELECT MAX(Price) FROM Products);
4
6. Display the Category name of the product which
was ordered in quantity=33.
Syntax
SELECT cat.CategoryName
FROM Categories AS cat JOIN Products AS pro ON
cat.CategoryID = pro.CategoryID
JOIN OrderDetails AS orddet ON pro.ProductID =
orddet.ProductID
WHERE orddet.Quantity LIKE '33';
Screenshot
5
7. Display the Product name which has the highest quantity of
order.
Syntax
SELECT pro.ProductName
FROM Products pro JOIN OrderDetails od ON pro.ProductID =
od.ProductID
WHERE od.Quantity = (SELECT MAX(Quantity) FROM
OrderDetails);
6
8. Display the Customer names who placed an order after
‘1997-02-07’.
Syntax
SELECT CustomerName
FROM Customers cus JOIN Orders ord ON cus.CustomerID =
ord.CustomerID
WHERE '1997-02-07' < ord.OrderDate;
Screenshot
7
9. Display the Customer names who ordered less than
quantity=2 in their orders.
Syntax
SELECT CustomerName
FROM Customers cus JOIN Orders ord ON
cus.CustomerID = ord.CustomerID
JOIN OrderDetails orddet ON ord.OrderID =
orddet.OrderID
WHERE orddet.Quantity < 2;
Screenshot
8
10. Display the sum of the price of products that was
ordered in the OrderID=10263.
Syntax
SELECT SUM(Price)
FROM Products pro JOIN OrderDetails ord ON
pro.ProductID = ord.ProductID
WHERE ord.OrderID = '10263';
Screenshot
9
10