This is the question on w3resource:
You can see the content of the table on the link above.
This is my solution:
FROM SALESMAN S WHERE S.SALESMAN_ID IN
FROM CUSTOMER C
WHERE S.NAME < C.CUST_NAME
FROM salesman a
FROM CUSTOMER b
WHERE a.name < b.cust_name);
The two queries are not the same, as I will explain. There is nothing wrong with your query or your single record result set, as this demo shows:
This query is finding every salesman which has at least one customer whose name is lexicographically greater than his own. Only salesman James Hoog has a name which is lexicographically less than any of his customers.
On the other hand, the query from the website is looking for salesman names which are lexicographically less than any customer (either his own or someone else's) from each record in the
Salesman table. This is a much more lax requirement than what is used in your query. The logic here is to retain any salesman for which there exist any customers whose name is greater than that of the salesman. Only Pit Alex and Paul Adam fail to meet this requirement, there being no customers whose last name begin with the letter 'P' or any letter greater than that.