Do You Have a Quarter?

Many of you probably have a change jar somewhere—a container full of coins. From time to time, you might dig into your change jar to find a quarter,[1] and the process of doing so is probably second nature. Partly because it’s so familiar, the process of retrieving a quarter from a change jar will be a useful example for the discussion of algorithms and complexity. While a coin isn’t exactly data, retrieving a quarter is much like executing this T-SQL SELECT query:

SELECT TOP (1) Coin
FROM ChangeJar
WHERE Denomination = 0.25
ORDER BY (SELECT NULL);

How to Retrieve a Quarter from a Coin Jar

I’m sure you know more than one algorithm for executing this task—to retrieve a quarter from a coin jar. Most of the time, you look into ...

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.