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
2019-11-18 14:05:53 +01:00

7 lines
337 B
SQL

/*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;