DBMS AP21110011442 Final lab
DBMS AP21110011442 Final lab
DBMS AP21110011442 Final lab
SELECT ot.ord_no,
ot.purch_amt,
ot.ord_date,
ot.cust_id AS customer_id,
ot.salesman_id
FROM Order_Table ot
WHERE ot.ord_date = '2021-10-10'
AND ot.purch_amt > (
SELECT AVG(purch_amt)
FROM Order_Table
WHERE ord_date = '2021-10-10'
);
SELECT
ct.cust_name AS "customer",
ct.grade AS "Grade",
ot.ord_no AS "OrderNo"
FROM
Customer_table ct
JOIN
Order_Table ot ON ct.cust_id = ot.cust_id
JOIN
Salesman_table st ON ct.salesman_id = st.Salesman_id
WHERE
ct.grade IS NOT NULL
ORDER BY
ct.cust_id, ot.ord_no;
SELECT ot.ord_no,
ot.purch_amt,
ot.ord_date,
ot.cust_id AS customer_id,
ot.salesman_id
FROM Order_Table ot
JOIN (
SELECT cust_id, AVG(purch_amt) AS avg_amount
FROM Order_Table
GROUP BY cust_id
) AS avg_table ON ot.cust_id = avg_table.cust_id
WHERE ot.purch_amt > avg_table.avg_amount;
Output:
1) find those sales people who generated orders for their customers
but not located in the same city . return
ord_no,cust_name,customer_id(orders table) ,salesman_id
(orderstable)
2) from the orders table find the order values greater than the
average order value of 10th october 2021 . return
ord_no,purch_amt,ord_date,customer_id,saleman_id.
3) make a list of the salesman who either work for one
or more customers. The customer may have placed ,
either one or more orders on or above order
amount 2000 and must have a grade