Posts

Showing posts from October, 2014

Understanding DB2 OLAP By Example

The OLAP features in DB2 are very cool however I don't see a lot of people using them. In addition, sometimes reading the docs on these features are overwhelming so hopefully these examples will make it easy to understand. We'll look at the following OLAP features in particular. There are more available if you navigate to the IBM website for your DB2 version. Rollup Cube Grouping Set Rank Dense Rank Row Number  First we need to create a sample table and data: CREATE TABLE sales( item VARCHAR(20), state CHAR(2), store VARCHAR(20), amount DECIMAL); Then lets insert some sample data: INSERT INTO sales VALUES('Watch', 'IL', 'Buymore', 15); INSERT INTO sales VALUES('Watch', 'NY', 'Buymore', 15); INSERT INTO sales VALUES('Watch', 'NY', 'Buymore', 15); INSERT INTO sales VALUES('Watch', 'NY', 'Buymore', 15); INSERT INTO sales VALUES('Watch', '