O'Reilly logo

Inside Microsoft® SQL Server™ 2005: T-SQL Querying by Dejan Sarka, Lubor Kollar, Itzik Ben-Gan

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

Histograms

Histograms are powerful analytical tools that express the distribution of items. For example, suppose you need to figure out from the order information in the Orders table how many small, medium, and large orders you have, based on the order quantities. In other words, you need a histogram with three steps. What defines quantities as small, medium, or large are the extreme quantities (the minimum and maximum quantities). In our Orders table, the minimum order quantity is 10 and the maximum is 40. Take the difference between the two extremes (40 – 10 = 30), and divide it by the number of steps (3) to get the step size. In our case, it’s 30 divided by 3 is 10. So the boundaries of step 1 (small) would be 10 and 20; for step 2 (medium), ...

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