Question

IV. Write and execute the following SQL Queries:

1.Retrieve all orders along with the customer details who placed the order.

2. Find all products that have been ordered by a specific customer.

3. Retrieve the total sales for each product.

4. Find all customers who have placed at least one order.

5. Retrieve the total quantity of products ordered by each customer.

6. Find all orders and their order details for a specific customer.

7. Retrieve all products along with the total quantity ordered.

8. Find the total revenue generated from orders placed within a specific date range.

9. Retrieve all customers who have ordered a specific product.

10. Find the most frequently ordered product.

11. Retrieve the average order value for each customer.

12. Find all products that have never been ordered.

13. Retrieve the total number of orders placed each month.

14. Retrieve the total number of products ordered in each order.

15. Find the top 5 customers based on total spending.

16. Retrieve all orders placed on a specific date.

17. Find the total number of unique products ordered by each customer.

18. Retrieve the order details for the order with the highest total price.

19. Find the top 3 products based on the total quantity ordered.

20. Retrieve the total sales for each month.

21. Find the customer who has placed the most orders.

22. Retrieve the total number of orders for each status.

23. Find the order with the highest quantity of a single product.

24. Retrieve the customer details for the order with the highest total price.

25. Find the average quantity of products ordered per order.

28 May 2025
Answer :
Word Count : 512
Assuming the following relational schema in the DBMS Lab context: * `Customers(CustomerID, Name, Email, ...)` * `Orders(OrderID, CustomerID, OrderDate, TotalAmount, Status, ...)` * `OrderDetails(OrderDetailID, OrderID, ProductID, Quantity, UnitPrice)` * `Products(ProductID, ProductName, Price, ...)` Here are the SQL queries for the tasks: 1. ```sql SELECT Orders.*, Customers.* FROM Orders JOIN Customers ON Orders.CustomerID = Customers.CustomerID; ``` 2. ```sql SELECT DISTINCT Products.* FROM Products JOIN OrderDetails ON Products.ProductID = OrderDetails.ProductID JOIN Orders ON OrderDetails.OrderID = Orders.OrderID WHERE Orders.CustomerID = 'specific_customer_id'; ``` 3. ```sql SELECT ProductID, SUM(Quantity * UnitPrice) AS TotalSales FROM OrderDetails GROUP BY ProductID; ``` 4. ```sql SELECT DISTINCT Customers.* FROM Customers JOIN Orders ON Customers.CustomerID = Orders.CustomerID; ``` 5. ```sql SELECT Orders.CustomerID, SUM(OrderDetails.Quantity) AS TotalQuantity FROM Orders JOIN OrderDetails ON Orders.OrderID = OrderDetails.OrderID GROUP BY Orders.CustomerID; ``` 6. ```sql SELECT Orders.*, OrderDetails.* FROM Orders JOIN OrderDetails ON Orders.OrderID = OrderDetails.OrderID WHERE Orders.CustomerID = 'specific_customer_id'; ``` 7. ```sql SELECT Products.ProductID, Products.ProductName, SUM(OrderDetails.Quantity) AS TotalOrdered FROM Products LEFT JOIN OrderDetails ON Products.ProductID = OrderDetails.ProductID GROUP BY
______ ______ _____ ___ ____ _____ __________ ____ ___.
_________ ___ ____ ____ _________ ________ ________.
______ _____ __________ _______ ____ _________ _______ ________ _______.
________ __________ ________ ______ _____ ___ __________ ______ _____.
___ ______ _______ __________ _____ _____ _________ __________ _______ ______ __________ _______.
_____ _________ _________ ____ ___ ________ _________ ____ ___.
___ _____ ___ _____ ________ _________ _________ _______ _____.
________ _____ __________ ________ _____ _______ __________ _______ _______ __________.
________ _________ _________ __________ _______.
_______ _______ __________ _______ _________ __________ ____ _____.
________ _________ _____ _________ ______ _________ ___ ______ _______.
________ ________ ___ ___ __________ ___.
_______ ____ _______ ___ ___ ____ ________ ____ ____ ______ ___ ______.
____ ___ __________ ___ ___ ___ ___ _____ _____ ________ _______.
_____ _____ __________ ______ ____.
_______ ___ __________ _____ ______ ____ ________ ____.
__________ __________ _________ _______ ___ __________ ________ _______ ___ ___ ____.
________ ______ ____ ______ ________ ______ ____ ____ __________.
__________ _________ _____ __________ _____ ________ _________ ______ ___.
_________ _____ ______ _______ ____ ________ _________ ______ _________ ___ __________.
______ _____ ___ ______ ___ ___ ___ __________ ____ __________.
______ _____ ________ ___ _______ _______ ____.
_____ __________ ____ ________ _____ ______ _____ ____ _____ ________.
____ _____ ___ ___ ________ ______ ________ ____ ___ ________ ____ ________.
____ _____ _______ ___ __________ ______.
_____ ___ _________ _______ ______ _________ ______ _____ ________ _____ ______ _____.
__________ ________ ______ _________ ______ ___ _________ _____ __________.
____ _______ ________ __________ ______ ____ _________ _______ ___ ____.
_______ _________ _______ _______ _________ ___ ________ _______ _______.
____ _____ _________ _____ _______ _____ ___ _____ ___ _____ _________.
________ ______ _____ ______ ____ _______ ____.
___ __________ _______ _________ ____ ________ ________ ________ _________.
________ _________ _____ ______ _________.
________ __________ _______ __________ ______ ____ ________ _________ _______ __________.
__________ _________ _______ _______ _____ ___ _____.
___ _____ __________ _____ ______ _____ ___ ___.
______ __________ _______ ______ _________.
________ ___ ___ ____ _______.
_______ ___ _____ ____ _______ _________ ____ _________.
______ ____ ___ ____ _________ ________ ________ ___ ____ _______.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU BCSL 34 2024 2025 - IV. Write and execute the following SQL Queries:1.Retrieve all ord | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→