Summary Exercise—Relational Division

As a summary exercise, you’re given the following task for cases in which you might want to consider using temporary objects: in the Northwind database, you need to determine which customers have orders handled by the same set of employees. The result set should contain a row for each customer, with the customer ID, and a value representing the group of employees. The latter is expressed as the minimum customer ID out of all customers that share the same set of employees. That is, if customers A, B, and C were handled by the same set of employees (for example, 3, 7, 9), the result set would contain {(A, A), (B, A), (C, A)}. Return NULL for customers that have no orders. The desired result is shown in Table 2-5 ...

Get Inside Microsoft® SQL Server™ 2005 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.