(一) 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])