Lab
Lab
/* Find customers whose payments are greater than the average payment */
select avg(amount)
from payments;
/* Find the maximum, minimum and average number of items in sale orders */
/* Find products whose buy prices are greater than the average buy price of all
productsin each product line */
/* Find sales orders whose total values are greater than 60k */
********************************************************************************
/* Q.1 : Show all customer who purchased products from the date 17/08/2016 to
05/10/2016 except the 10/09/2016. */
select* from customer c inner join orders o
on o.customer_id = c.customer_id
where order_date between "2016-08-17" and "2016-10-05" and order_date <> "2016-09-
10" ;
/*Q3. Find the highest purchase amount ordered by the each customer on a particular
date with their ID, order date and highest purchase amount.*/
select customer.customer_id, orders.order_date , sum(orders.purch_amt) as Sum_amt
from customer inner join orders
on orders.customer_id = customer.customer_id
group by customer_id
order by Sum_amt desc;
/*Q4. Find the names of all customers along with the salesmen who works for them*/
/*Q5. Display all the orders which values are greater than the average order value
for 10th October 2012*/