programming-examples/sql/View/7. Write a query to create a view that finds the salesman who has the customer with the highest order of a day.sql
2019-11-18 14:05:53 +01:00

9 lines
376 B
SQL

/*7. Write a query to create a view that finds the salesman who has the customer with the highest order of a day. */
CREATE VIEW elitsalesman
AS SELECT b.ord_date, a.salesman_id, a.name
FROM salesman a, orders b
WHERE a.salesman_id = b.salesman_id
AND b.purch_amt =
(SELECT MAX (purch_amt)
FROM orders c
WHERE c.ord_date = b.ord_date);