The SQL of OLAP > > Intelligent Enterprise: Better Insight for Business Decisions

Welcome Guest. | Log In| Register | Membership Benefits

Intelligent Enterprise

Better Insight for Business Decisions

Intelligent Enterprise - Better Insight for Business Decisions
search Intelligent Enterprise
RSS
Webcasts
Digital Library
Subscribe
Home


  • EMAIL
  • PRINT
  • REPRINTS
  • Follow Us on Twitter
  • FOLLOW US
  • Share

The SQL of OLAP


Don't overlook the underpinning - and core strength - of your OLAP technology solution.

Don't overlook the core strength of your OLAP technology solution: SQL.


By Michael Gonzales
September 18, 2004

Page 2

Grouping capabilities are critical to OLAP functionality. ROLLUP and CUBE are extensions of the GROUP BY clause. The functionalities of ROLLUP and CUBE are often referred to as supergroups.

  • A ROLLUP group is an extension to the GROUP BY clause that produces a result set that contains subtotal rows in addition to the "regular" grouped rows. Subtotal rows are superaggregate rows that contain further aggregates whose values are derived by applying the same column functions that were used to obtain the grouped rows. A ROLLUP grouping is a series of grouping-sets:

    GROUP BY ROLLUP (a,b,c) is equivalent to:

    GROUP BY GROUPING SETS
    (
    (a,b,c)
    (a,b)
    (a)
    ()
    )

Notice that the n elements of the ROLLUP translate to an n+1 grouping set. Another point to remember is that the order in which the grouping expressions are specified is significant for ROLLUP.

  • The CUBE supergroup is the other extension to the GROUP BY clause that produces a result set that contains all the subtotal rows of a ROLLUP aggregation and, in addition, contains "cross-tabulation" rows. Cross-tabulation rows are additional superaggregate rows. They are, as the name implies, summaries across columns as if the data were represented as a spreadsheet. Like ROLLUP, a CUBE group can also be thought of as a series of grouping-sets. In the case of a CUBE, all permutations of the cubed grouping expression are computed along with the grand total. Therefore, the n elements of a CUBE translate to 2n grouping-sets.

    GROUP BY CUBE (a,b,c) is equivalent to:

    GROUP BY GROUPING SETS
    (
    (a,b,c)
    (a,b)
    (a,c)
    (b,c)
    (a)
    (b)
    (c)
    ()
    )


    Notice that the three elements of the CUBE translate to eight grouping sets. Unlike ROLLUP, the order of specification of elements doesn't matter for CUBE: CUBE (DayOfYear, Sales_Person) is the same as CUBE (Sales_Person, DayOfYear).

    CUBE is an extension of the Rollup function. The CUBE function not only provides the column summaries we saw in rollup but also calculates the row summaries and grand totals for the various dimensions.

Aside from these functions, the ability to define a window is equally important to SQL's OLAP functionality. You use windows to define a set of rows over which a function is applied and the sequence in which it occurs. Another way to view the concept of a window is to equate it with the concept of a slice. In other words, a window is simply a slice of the overall data domain.


  • EMAIL
  • PRINT
  • REPRINTS
  • Follow Us on Twitter
  • FOLLOW US
  • Share


 





New on the BLOG
Text Data Quality: Mistakes and More
11.25.2009
blog author
Seth Grimes
I wrote recently on Text Data Quality, looking at issues that affect analytical accuracy, that "the basic text data quality issue is that humans make mistakes, and the challenge is that people's natural-language mistakes defy easy, automated detection." This topic and related non-erroneous vagaries of human language bear further exploration...

Read more from Seth Grimes >>

Curt Monash
Reports of Perfectly-Balanced Hardware Configurations are Greatly Exaggerated
Data warehouse appliance and software appliance vendors like to claim that they've worked out just the right hardware configuration(s), and that a single configuration is correct for a fairly broad range of workloads. But there are a lot of reasons to be dubious about that. Specific vendor evidence includes...

11.24.2009
Read more from Curt Monash >>

Google Chrome OS: Don't Link it to Cloud Computing
11.23.2009
blog author
David Linthicum
With much fanfare, the Google Chrome OS launched last week. Chrome OS is a Web operating system that boots quickly, right into a browser... We've been here before... And I would rather not bind Chrome to cloud computing because I don't think the OS will be around long.

Read more from David Linthicum >>



Intelligent Enterprise Newsletters
Subscribe Here:
*Email:
 First Name:
 Last Name:
  Intelligent Enterprise Blogosphere Newsletter:
  Intelligent Enterprise Newsletter:

Email Type: