Summarizing Data with CUBE Queries

April 30, 2003

[From 4GuysFromRolla.com]

One of the motivations behind using databases to hold information is so that decisions can be made on the data. For example, the benefit of a retailer storing product sales information in a database is that the retailer can examine reports on the data, showing interesting facts, such as what products are the top sellers, where a particular item is selling best, the gross revenue generated from all sales of a particular item or store, and so on.

Typically, interesting data has different dimensions. A dimension can be thought of as an attribute with a set of possible values. In the database world, this maps to a table column. For example, an eCommerce store might have a table tracking all sales, with a record for each item sold. One dimension is the item that was sold; another, the store from which is was sold. Oftentimes, it is useful to view summary data for a particular dimension, such as all items sold at a particular store, or all of the sales for a particular store. In this article we'll examine how to use native SQL commands to provide such summary queries!

The article continues at http://www.4guysfromrolla.com/webtech/043003-1.shtml