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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.