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

9 lines
330 B
SQL

/*8. Write a query to create a view that finds the salesman who has the customer with the highest order at least 3 times
on a day.*/
CREATE VIEW incentive
AS SELECT DISTINCT salesman_id, name
FROM elitsalesman a
WHERE 3 <=
(SELECT COUNT (*)
FROM elitsalesman b
WHERE a.salesman_id = b.salesman_id);