MDX in SQL Server 2008 Szymon Wilk (na podstawie materiałów przygotowanych przez Krzysztofa...

Post on 12-Jan-2016

227 views 2 download

Transcript of MDX in SQL Server 2008 Szymon Wilk (na podstawie materiałów przygotowanych przez Krzysztofa...

MDX in SQL Server 2008

Szymon Wilk(na podstawie materiałów przygotowanych przez Krzysztofa Dembczyńskiego)

TWO, 2009/10

Preparation

1. Download the data cube (project from the last tutorial) https://ophelia.cs.put.poznan.pl/webdav/dm/students/winter_2009/

2. Introduce necessary changes to the project configuration

3. Deploy the data cube

4. Connect to the data cube (Analysis Services)

5. Create and execute specific MDX queries

Changing the Project Configuration

Change the connection string Verify the impersonation settings

Changing the Project Configuration

Change the project properties ( deployment settings)

Connecting to the Data Cube

Connect to Analysis Services (not Database Engine)

Connecting to the Data Cube

Navigate to the deployed data cube (OLAP Tutorial Analysis Services Tutorial) and open a new query window

Query 1

Show the sales amount in March 2002 and April 2002 (Due Date dimension; rows) grouped by gender (columns)

Query 1 – Solution

Query 2

Show the sales amount between February and November 2002 (rows) grouped by gender (columns)

Query 2 – Solution

Query 3

Show the sales amount for all months (rows) grouped by gender (columns)

Query 3 – Solution

Query 4

Show the sales amount for all 2002 quarters (rows) grouped by gender (columns)

Query 4 – Solution

Query 5

Show the sales amount for all years and product lines (rows) grouped by gender (columns)

Query 5 – Solution

Query 6

Show the sales amount (total over all years) for these product lines, for which the total sales in 2001 exceeded 600,000$ (rows), grouped by gender (columns)

Query 6 – Solution

Query 7

Show the sales amount (total over all years) for all products (Product Name) from the Road product line (rows), grouped by gender (columns). Products should be ordered by the order quantity.

Query 7 – Solution

Query 8

Show the sales amount and the order quantity over all products (columns) in 2001 and 2002 (rows). Also calculate in an additional column the average order value (sales amount / order quantity)

Calculate in an additional row the difference between 2002 and 2001 for all reported measures/values

Query 8 – Solution