Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何在mdx中获得前5名_Sql_Sql Server_Ssas_Mdx - Fatal编程技术网

Sql 如何在mdx中获得前5名

Sql 如何在mdx中获得前5名,sql,sql-server,ssas,mdx,Sql,Sql Server,Ssas,Mdx,如何从mdx查询中获得前5名 我对这个问题有一个疑问: WITH SET [Geography].[City] AS TopCount( [Geography].[City] ,5 ,[Measures].[Reseller Freight Cost] ) SELECT NON EMPTY { CROSSJOIN( { [Date].[Calendar] }, {

如何从mdx查询中获得前5名

我对这个问题有一个疑问:

WITH SET [Geography].[City] AS  
   TopCount(
      [Geography].[City]
      ,5
      ,[Measures].[Reseller Freight Cost]
   ) 
SELECT
  NON EMPTY {
    CROSSJOIN(
      {
        [Date].[Calendar]
      },
      {
        [Product].[Category]
      }
    ),
    CROSSJOIN(
      {
        [Date].[Calendar].children
      },
      {
        [Product].[Category]
      }
    )
  } DIMENSION PROPERTIES children_cardinality, parent_unique_name ON COLUMNS,
  NON EMPTY {
    [Geography].[City],
    [Geography].[City].children
  } DIMENSION PROPERTIES children_cardinality, parent_unique_name ON ROWS
FROM [Adventure Works]
WHERE (
        [Measures].[Reseller Freight Cost]
      )  
但它不起作用。 现在我有错误了 错误:{“faultstring”:“查询(1,21)解析器:.”的语法不正确。”,“faultcode”:“XMLAnalysisError.0xc10e0002”}


最好不要在选择word后更改代码。

创建集合时,只需声明它,而不包含关联的层次结构,因此这是错误的
[Geography].[City]

此外,交叉连接还有一种更具可读性的语法-只需使用星号
*

试试这个:

WITH SET [CitySet] AS  
   TopCount(
      [Geography].[City]
      ,5
      ,[Measures].[Reseller Freight Cost]
   ) 
SELECT
  NON EMPTY {
       [Date].[Calendar] * [Product].[Category]
      ,[Date].[Calendar].children * [Product].[Category]
  } DIMENSION PROPERTIES children_cardinality, parent_unique_name ON COLUMNS,
  NON EMPTY {
    [CitySet],  //<<changed here [Geography].[City],
    [Geography].[City].children
  } 
  DIMENSION PROPERTIES children_cardinality, parent_unique_name ON ROWS
FROM [Adventure Works]
WHERE (
        [Measures].[Reseller Freight Cost]
      )  
将[CitySet]设置为
头号人物(
[地理][城市]
5.
,[措施][转销商运费]
) 
挑选
非空{
[日期][日历]*[产品][类别]
,[日期][日历].儿童*[产品][类别]
}维度属性列上的子项\u基数、父项\u唯一\u名称,
非空{
[城市网],//