You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
541 B
SQL

/*9. Write a query that produces the name and number of each salesman and each customer with more than one current order.
Put the results in alphabetical order.*/
SELECT customer_id, cust_name
FROM customer a
WHERE 1<
(SELECT COUNT (*)
FROM orders b
WHERE a.customer_id = b.customer_id)
UNION
SELECT salesman_id, name
FROM salesman a
WHERE 1 <
(SELECT COUNT (*)
FROM orders b
WHERE a.salesman_id = b.salesman_id)
ORDER BY 2;