SubSelect MDX Query作为主查询的过滤列表

时间:2017-03-17 14:31:35

标签: subquery mdx

SubSelect MDX Query作为主查询的过滤列表

大家好 我想像SQL一样编写MDX查询:

select a, b, sum(x) from table1 where b = "True" and a in (select distinct c from table2 where c is not null and d="True") group by a,b

我尝试这样的事情:

`大家好 我想像SQL一样编写MDX查询:

select a, b, sum(x) from table1 where b = "True" and a in (select distinct c from table2 where c is not null and d="True") group by a,b

我尝试这样的事情:

    SELECT 
 NON EMPTY { [Measures].[X] } ON COLUMNS, 
 NON EMPTY { [A].[Name].[Name] 
  *[B].[Name].[Name].&[True]
  } ON ROWS
 FROM
 (
  SELECT 
    { ([A].[Name].[Name] ) } ON 0 
     FROM 
    ( SELECT ( 
        {EXCEPT([C].[Name].ALLMEMBERS, [C].[Name].[ALL].UNKNOWNMEMBER) }) ON COLUMNS 
        FROM
         ( SELECT ( 
         { [D].[Name].&[True] } ) ON COLUMNS 
         FROM [CUBE])) 
  )

但它从子查询中返回 x 的总和。

应该怎么样? '

1 个答案:

答案 0 :(得分:1)

X&C的测量组是否与D维度有关系?如果确实如此,则以下代码必须正常工作:

 Select 
 [Measures].[X] on 0, 
 Non Empty [A].[Name].[Name].Members * [B].[Name].&[True] on 1
 From [CUBE]
 Where ([D].[Name].&[True])

如果你有多对多的关系,你需要一个额外的措施(比如Y):

Select 
[Measures].[X] on 0, 
Non Empty NonEmpty([A].[Name].[Name].Members,[Measures].[Y]) * [B].[Name].&[True] on 1
From [CUBE]
Where ([D].[Name].&[True])