Structure of the Basic MDX Query

To specify a dataset, a Multidimensional Expressions (MDX) query must contain the following information:

  • The number of axes (up to 128)
  • The members from each dimension to include on each axis
  • The name of the cube that sets the context
  • The members from a slicer dimension on which data is sliced for members from the axis dimensions

This information can be complex. MDX syntax provides the information in a simple and straightforward manner, using the MDX SELECT statement.

Basic MDX Syntax: SELECT Statement

In MDX, the SELECT statement is used to specify a dataset that contains a subset of multidimensional data. A basic MDX query is structured in the following way:

SELECT [<axis_specification>
       [, <axis_specification>...]]
  FROM [<cube_specification>]
[WHERE [<slicer_specification>]]

The basic MDX SELECT statement contains a SELECT clause and a FROM clause, with an optional WHERE clause. These syntax elements are shown in the following example:

SELECT
   { [Measures].[Unit Sales], [Measures].[Store Sales] } ON COLUMNS,
   { [Time].[1997], [Time].[1998] } ON ROWS
FROM Sales
WHERE ( [Store].[USA].[CA] )

The SELECT clause determines the axis dimensions of an MDX SELECT statement. Two axis dimensions are defined in this MDX query example.The FROM clause determines which multidimensional data source is to be used when extracting data to populate the result set of the MDX SELECT statement.

A WHERE clause optionally determines which dimension or member to use as a slicer dimension; this restricts the extracting of data to a specific dimension or member. The WHERE clause in this example restricts the data extract for the axis dimensions to a specific member of the Store dimension. An MDX SELECT statement supports other optional syntax elements, such as the WITH keyword, and the use of MDX functions to construct members by calculation for inclusion in an axis or slicer dimension.

SQL and MDX

The syntax format of the MDX SELECT statement is similar to that of SQL syntax; however, there are several primary differences:

  • MDX syntax distinguishes sets by surrounding tuples or members with braces (the { and } characters.) MDX queries can have up to 128 axis dimensions in the SELECT statement, but only the first 5 axes have aliases. An axis can be referred to either by its ordinal position within an MDX query, or by its alias if it has been assigned an alias. In the previous example, the COLUMNS and ROWS axis aliases are used. The example query could also have been written in the following way, using the ordinal position of each axis:
  • SELECT
       { [Measures].[Unit Sales], [Measures].[Store Sales] } ON AXIS(0),
       { [Time].[1997], [Time].[1998] } ON AXIS(1)
    FROM Sales
    WHERE ( [Store].[USA].[CA] )
  • As with an SQL query, the FROM clause names the source of the data for the MDX query. However, unlike an SQL query, the FROM clause in an MDX query is restricted to a single cube. Information from other cubes can be retrieved, however, on a value-by-value basis using the LookupCube function.
  • In the MDX query, the WHERE clause describes the slicer dimensions. If a dimension is not mentioned as part of the WHERE clause, Microsoft SQL Server 2000 Analysis Services assumes that any dimension not assigned to an axis dimension is a slicer dimension, and the dimension is filtered on its default members. The WHERE clause can change the filtering process for specified dimensions, allowing fine control of included data.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值