A Practical Application

At the beginning of this chapter, we considered a set S—the set of all customers for whom every employee from the USA has handled at least one order. We’ll finish the chapter by considering the set S once again, from a different perspective, and turn the result into a query. I’ll also show you how to represent the characteristic function of a set in SQL.

Run the following T-SQL batch to set the database context for this section’s queries:

USE InsideTSQL2008;
GO

In set-builder notation, we were able to write S in this way:

  • S = {c∈Customers : ∀e∈USAEmployees (∃o∈Orders: (handled(e,o,c)))}

Consider the overall form of this definition in the following way: S is the set of customers for which something is true for every USA employee. ...

Get Inside Microsoft® SQL Server® 2008: T-SQL Querying now with O’Reilly online learning.

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