3.3. MDX Query

Chapter 2 introduced you to the MDX SELECT statement. The syntax for an MDX query is as follows

[WITH <formula_expression> [, <formula_expression> ...]]
SELECT [<axis_expression>, [<axis_expression>...]]
FROM [<cube_expression>]
[WHERE [slicer_expression]]

You might be wondering whether the SELECT, FROM, and WHERE format is similar to the Structured Query Language (SQL), serve a purpose similar to SQL. Even though the SELECT-FROM-WHERE looks identical to SQL in MDX, you can do more complex operations in MDX. You learn some of these operations in this chapter and throughout the book.

The keywords WITH, SELECT, FROM, and WHERE along with the expressions following them are together referred to as a clause. In the preceding MDX query template anything specified within the square brackets means it is optional; that is, that section of the query is not mandatory in every MDX query.

You can see that the WITH and WHERE clauses are optional because they are enclosed within [ and ] characters. Therefore, you might be thinking that the simplest possible MDX query should be the following

SELECT
FROM [Adventure Works]

Super! You are absolutely correct. This MDX query returns a single value; the tuple corresponding to this value uses the default members of the dimension to retrieve the value. You might recall that the fact data is stored in a special dimension called Measures. When you send the preceding query to the Analysis Services instance you get the default member from ...

Get Professional SQL Server™ Analysis Services 2005 with MDX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.