Professional Microsoft® SQL Server® Analysis Services 2008 with MDX
by Sivakumar Harinath, Matt Carroll, Sethu Meenakshisundaram, Robert Zare, Denny Guang-Yeu Lee
3.3. MDX Queries
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 clauses are the same as those in Structured Query Language (SQL). Even though they look identical to those in SQL, the MDX language is different and supports more complex operations. You learn about 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 referred to as a clauses. In the preceding MDX query template, anything specified within square brackets means it is optional; that is, that section of the query is not mandatory in an MDX query.
You can see that the WITH and WHERE clauses are optional because they are enclosed within square brackets. 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. Which value, you might ask? Recall that fact data is stored in a special dimension called Measures. When you send the preceding query to the Analysis Services instance, you get the value of the default member from the Measures dimension which, for the Adventure Works cube, is Reseller Sales Amount from the Reseller ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access