Question 1
select customerid, count(*) as totalorders from orders
group by customerid
Question 2
select orderid, sum(quantity) as totalquantity, avg(unitprice) as avgprice
from orderdetails
group by orderid
Question 3
select customerid, count(*) as totalorders from orders
group by customerid
order by totalorders desc
limit 5
Question 4
select customerid, count(*) as totalorders from orders
group by customerid
having count(*) > 5
Question 5
select productid, sum(unitprice*quantity) as revenue from orderdetails
group by productid
Question 6
select productid, round(avg(unitprice)) as avgprice from orderdetails
group by productid
having avg(unitprice) > 50
Question 7
select productid, max(unitprice) as maxprice from orderdetails
group by productid
Question 8
select employeeid, count(distinct (customerid)) as
number_of_customers_in_97 from orders
where orderdate between '1997-01-01' and '1997-12-31'
group by employeeid
order by employeeid