Skip to content
Advertisement

SQL ANSI: How to apply the “division operation” with 4 tables?

I would like to try to fetch “all employees names that sold all books“:

enter image description here

I’ve tried this:

I need to write using SQL ANSI because this query will run on MySQL, Postgres, SQL Server & Oracle.

Advertisement

Answer

Your question is a little unclear. Assuming I’m understanding correctly, you want to know which employees sold every book, regardless if it was the same purchase or different purchases. Here’s one approach using aggregation:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement