常用MDX查询

MSDN MDX

1 TOPCOUNT

类似的还有BOTTOMCOUNT HEAD TAIL

SELECT [Measures].[Internet Sales Amount] ON 0, 



TOPCOUNT([Date].[Date].[Date].MEMBERS, 10, [Measures].[Internet Sales Amount]) 



ON 1 



FROM [Adventure Works] 
View Code

2 ORDER

SELECT 



Measures.[Reseller Order Count] ON COLUMNS, 



Order( 



[Date].[Calendar].[Calendar Quarter].MEMBERS 



,Measures.[Reseller Order Count] 



,DESC 



) ON ROWS 



FROM [Adventure Works]
View Code

3 范围运算符(:)

如:04年1月到04年3月

{

[Ship Date].[Calendar].[Month].&[2004]&[1] : 

[Ship Date].[Calendar].[Month].&[2004]&[3]

}
View Code

4 Aggregate

这个函数可以用来计算时间范围内的累计值

WITH MEMBER [Date].[Calendar].[First8Months2003] AS

    Aggregate(

        PeriodsToDate(

            [Date].[Calendar].[Calendar Year], 

            [Date].[Calendar].[Month].[August 2003]

        )

    )

SELECT 

    [Date].[Calendar].[First8Months2003] ON COLUMNS,

    [Product].[Category].Children ON ROWS

FROM

    [Adventure Works]

WHERE

    [Measures].[Order Quantity]
View Code

5 Filter

返回根据搜索条件对指定集进行筛选后得到的集,下面一个类似sql里like的写法

with

set [ProductType] as

filter(

     [Dim_ProductType].[ProductType].[ProductType],

     vbamdx!INSTR([Dim_ProductType].[ProductType].CURRENTMEMBER.Name,'U',1>=1)

)

select {

    [Measeures].[ProductCount]

} on columns,{

    [ProductType] 

} on rows

from [ProductInfo]
View Code

 

 

你可能感兴趣的:(查询)