MDX查询学习笔记1-元组和集合

(一) Cube结构--维度和度量

维度(Dimension): 维度提供了分类描述,表示一类分析角度,用户通过维度来分析度量数据。

维度层次(Hierarchy):一个维度可以包含级别的层级结构,级别表示特定的分类.比如,地区维度可以包含级别层级:Country、State、City。每个级别比它的父级别在数据粒度上更加细粒度。

维度成员(Member):一个成员是维度(包括度量维Measures)上的一个项目值,时间维度上“年”级别的成员可能有2000、2001

度量(Measures): 度量表示用来聚合分析的数字信息。

(二)元组和集合

 参考文献

元组:元组用于定义来自多维数据集的数据切片,它由来自一个或多个维度的单个成员的有序集合组成。

使用( )

SELECT 
WHERE (                  
[Date].[Calendar Year].[All Periods],                  
[Date].[Fiscal Year].[All Periods],                  
[Product].[Category].[Bikes],                  
[Product].[Subcategory].[Mountain Bikes],                  
[Measures].[Measures].[Reseller Sales Amount]        
)
FROM [Chapter 3 Cube]  

含义:含义为查询 Bikes 大类下的Mountain Bikes 所有的零售额。

集合:是零个、一个或多个元组的有序集合。

使用 {  }

案例:查询Accessories,Bikes,Clothing,Components 四类产品在2002-2004 财年美国的零售额。

方法1:

SELECT
{
            ([Date].[Calendar].[CY 2002],[Geography].[Country].[United States]),
            ([Date].[Calendar].[CY 2003],[Geography].[Country].[United States]),
            ([Date].[Calendar].[CY 2004],[Geography].[Country].[United States])
} ON COLUMNS,
{
            ([Product].[Category].[Accessories]),
            ([Product].[Category].[Bikes]),
            ([Product].[Category].[Clothing]),
            ([Product].[Category].[Components])
} ON ROWS
FROM [Step-by-Step]

方法2

 

SELECT
{
    ([Date].[Calendar].[CY 2002]),
    ([Date].[Calendar].[CY 2003]),
    ([Date].[Calendar].[CY 2004])
} ON COLUMNS,
{
    ([Product].[Category].[Accessories]),
    ([Product].[Category].[Bikes]),
    ([Product].[Category].[Clothing]),
    ([Product].[Category].[Components])
} ON ROWS
FROM [Step-by-Step]
WHERE ([Geography].[Country].[United States])

方法三:使用members 

SELECT
{
([Date].[Calendar].[CY 2002]),
([Date].[Calendar].[CY 2003]),
([Date].[Calendar].[CY 2004])
} ON COLUMNS,
{
 [Product].[Category].[Category].MEMBERS
} ON ROWS
FROM [Step-by-Step]
WHERE ([Geography].[Country].[United States])

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值