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.

12 lines
428 B
SQL

/*6. Write a query to list all the salesmen, and indicate those who do not have customers in their cities, as well as whose
who do.*/
SELECT salesman.salesman_id, name, cust_name, commission
FROM salesman, customer
WHERE salesman.city = customer.city
UNION
SELECT salesman_id, name, 'NO MATCH', commission
FROM salesman
WHERE NOT city = ANY
(SELECT city
FROM customer)
ORDER BY 2 DESC;