O'Reilly logo

Inside Microsoft® SQL Server® 2008: T-SQL Querying by Lubor Kollar Itzik Ben-Gan Dejan Sarka, and Steve Kass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required