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 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.