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
421 B
SQL

/*7. Write a query to that appends strings to the selected fields, indicating whether or not a specified salesman was matched
to a customer in his city.*/
SELECT a.salesman_id, name, a.city, 'MATCHED'
FROM salesman a, customer b
WHERE a.city = b.city
UNION
SELECT salesman_id, name, city, 'NO MATCH'
FROM salesman
WHERE NOT city = ANY
(SELECT city
FROM customer)
ORDER BY 2 DESC;