Basic MDX query (MDX syntax tutorial)

Source: Internet
Author: User

Basic MDX query (MDX syntax tutorial) favorites
The basic multidimensional expression (MDX) query is constructed in a similar way as in the following example:

Select [<axis_specification>
[, <Axis_specification>...]
From [<cube_specification>]
[Where [<slicer_specification>]
Basic MDX Syntax -- SELECT statement
In MDX, the SELECT statement is used to specify a dataset that contains a subset of multidimensional data. To discuss the syntax elements of the mdx select statement, this topic presents a basic MDX query example and decomposes it into various syntax elements to discuss the usage and structure of each element.

To specify a dataset, the MDX query must contain information about the following items:

Number of axes. Up to 128 axes can be specified in the MDX query.

Members from all dimensions must be included on each axis of the MDX query.

Set the name of the multi-dimensional dataset in the MDX query context.

A member from the slice dimension that slices data from the axis dimension.
This information may be complex. As you will see in this topic, the MDX syntax can provide such information in a simple and intuitive way using the mdx select statement.

Basic MDX query example
The following MDX query example is used to discuss the basic mdx select statement Syntax:

Select
{[Measures]. [unit sales], [measures]. [store sales]} on columns,
{[Time]. [1, 1997], [time]. [1998]} on rows
From sales
Where ([store]. [USA]. [Ca])
The basic mdx select statement contains a select clause, a from clause, and an optional where clause.

The Select clause determines the axis dimension of the mdx select statement. In this MDX query example, two axis dimensions are defined. For more information about the construction of the axis dimension in the select clause, see specify the axis dimension.

The from clause determines which multi-dimensional data source will be used when data is extracted to fill the result set of the mdx select statement. For more information about the from clause, see select statements.

The where clause can be used to determine which dimension or member is used as the slice dimension. This limits the data extraction to a specific dimension or member. In this MDX query example, the where clause is used to restrict data in the axis dimension to specific members in the store dimension. For more information about the construction of the slice dimension in the WHERE clause, see specify the slice dimension.

The mdx select statement supports other optional syntaxes such as the With keyword, and supports using the MDX function to construct members by calculating the content that should be included in the axis or slicer dimension. For more information about MDX select statements, see select statements.

The syntax format of the mdx select statement is similar to that of the SQL statement. However, you will notice the following significant differences:

The MDX syntax uses braces ({And} characters) to enclose tuples or members to identify a set. For more information about the member, tuples, and set syntax, see members, tuples, and collections.

Mdx queries can have a maximum of 128 axis dimensions in a select statement, but only the first five axes have aliases. The axis can be referenced using its sequential position in the MDX query or its alias (if an alias is assigned to it. In the preceding MDX query example, columns and rows axis aliases are used. This MDX query can also be written in the following way using the sequential positions 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])
Like SQL queries, the from clause is the source of the specified data for MDX queries. However, unlike SQL queries, the from clause in mdx queries is limited to a single multi-dimensional dataset. Information from other multidimensional datasets can also be retrieved by using the lookupcube function.

The where clause is used to describe the slice dimension. If a dimension is not proposed as part of the WHERE clause, Microsoft SQL Server 2000 Analysis Services assumes that any dimension not assigned to the axis dimension is the slice dimension, use its default members to filter the dimension. The where clause can change the filtering process for a specified dimension to precisely control the contained data.

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/welcomei/archive/2008/02/29/2132866.aspx

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/wentao308/archive/2009/11/08/4781997.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.