186k views
5 votes
Write a SELECT statement that returns the same result set as this SELECT statement. Substitute a subquery in a WHERE clause for the inner join.SELECT DISTINCT VendorNameFROM Vendors JOIN Invoices ON Vendors.VendorID = Invoices.VendorIDORDER BY VendorNameInsert one screen capture here that shows a single query with result that meets all of the above requirements.

1 Answer

4 votes

Answer:

SELECT DISTINCT VendorName FROM Vendors

WHERE VendorName= ANY (SELECT VendorName FROM Vendors JOIN Invoices ON Vendors.VendorID = Invoices.VendorID) ORDER BY VendorName;

Step-by-step explanation:

All bold faced words are sql keywords for different purposes. The subquery return the all values which matches the join condition and main query will choose only distinct values and make them in order of VendorName.

There many other queries also return the same result as returned by given query.

User Justin Standard
by
5.6k points