programming-examples/sql/View/11. Write a query to create a view that shows the average and total orders for each salesman after his or her name.sql

7 lines
317 B
MySQL
Raw Permalink Normal View History

2019-11-18 14:05:53 +01:00
/*11. Write a query to create a view that shows the average and total orders for each salesman after his or her name.
(Assume all names are unique)*/
CREATE VIEW norders
AS SELECT name, AVG(purch_amt), SUM(purch_amt)
FROM salesman, orders
WHERE salesman.salesman_id = orders.salesman_id
GROUP BY name;