programming-examples/sql/View/5. Write a query to create a view to keeping track the number of customers ordering, number of salesmen attached.sql

7 lines
337 B
MySQL
Raw Normal View History

2019-11-18 14:05:53 +01:00
/*5. Write a query to create a view to keeping track the number of customers ordering, number of salesmen attached, average
amount of orders and the total amount of orders in a day.*/
CREATE VIEW totalforday
AS SELECT ord_date, COUNT(DISTINCT customer_id),
AVG(purch_amt), SUM(purch_amt)
FROM orders
GROUP BY ord_date;