concept relational division in category sql
appears as: Relational division

This is an excerpt from Manning's book SQL Server MVP Deep Dives Vol. 2.
Relational division is one of the hardest-to-understand areas in relational theory because of the complexity involved. Yet relational division is one of the areas that can be most useful when programming for relational databases.
Listing 5. Code for relational division on multiple columns
SELECT sh.Stockholder FROM ( SELECT Stockholder, COUNT(*) AS Stockitems FROM StockholdersT GROUP BY Stockholder ) AS sh INNER JOIN ( SELECT COUNT(*) AS Stockitems FROM PortfolioT ) AS pf ON pf.Stockitems <= sh.Stockitems INNER JOIN StockholdersT AS s ON s.Stockholder = sh.Stockholder INNER JOIN PortfolioT AS p ON p.Stockname = s.Stockname AND p.Type = s.Type GROUP BY sh.Stockholder HAVING COUNT(*) = MIN(pf.Stockitems);