Professional Documents
Culture Documents
ASSIGNMENT – 8
Table: Orders
1. To calculate total purchase amount of all orders. Return total purchase amount.
Query: SELECT SUM(purch_amt) FROM orders;
Output:
2. To calculate the average purchase amount of all orders. Return average purchase
amount.
Query: SELECT AVG(purch_amt) FROM orders;
Name: Nidhi Bhutna
Section: CST (Roll no. 25)
University Roll No.: 2019723
Output:
Output:
6. To find the highest purchase amount ordered by each customer. Return customer ID,
maximum purchase amount.
Query: Select customer_id MAX (purch_amt) FROM orders GROUP BY customer_id;
Output:
7. To find the highest purchase amount ordered by each customer on a particular date.
Return, order date and highest purchase amount.
Query: Select customer_id, ord_date, MAX (purch_amt) From orders GROUP BY
customer_id, ord_date;
Output:
Name: Nidhi Bhutna
Section: CST (Roll no. 25)
University Roll No.: 2019723
9. To find the highest order (purchase) amount by each customer on a particular order
date. Filter the result by highest order (purchase) amount above 2000.00. Return
customer id, order date and maximum purchase amount.
Query: SELECT customer_id, ord_date, MAX(purch_amt) FROM orders
GROUP BY customer_id, ord_date
HAVING MAX (purch_amt > 2000.0);
Output: