MDX 查询 - 子选择实现 - Select 一列的所有值,一个除外
MDX query - Subselect implementation - Select all values of a column except one
我必须执行具有以下要求的查询。
1) 我需要多个条件(AND、OR)。
2) 在某些情况下,我需要排除具有特定值的记录。
SELECT {...} ON Columns, {...} ON ROWS
FROM
(SELECT {([Element1].[Value].&[98]&[002], [Element2].Value.&[Value1]),
([Element1].[Value].&[98]&[004], [Element2].Value.&[Value2]), ([Element1].[Value].&[98]&[005], [Element2].Value.NOTIN[value1, value2]), } ON Columns
FROM [CubeName])
我已经提到了 NOTIN[value1,value2]),因为我不知道如何实现它。除了提到的那些之外,我必须获得所有值。如果有人可以提供解决方案,请告诉我。
您通常会使用函数 EXCEPT
从集合中排除一些成员:
SELECT
{...} ON 0
, {...} ON 1
FROM
(
SELECT
EXCEPT(
[Element1].[Value].[Value].MEMBERS //<<name of the full set
,{ //<<the set to be excluded
[Element1].[Value].&[98]&[002],
[Element1].[Value].&[98]&[004],
[Element1].[Value].&[98]&[005]
} ON 0
FROM [CubeName]
);
以上可以扩展为元组,但第一个参数需要是交叉连接:
SELECT
{...} ON 0
, {...} ON 1
FROM
(
SELECT
EXCEPT(
[Element1].[Hier1].[Hier1].MEMBERS
* [Element1].[Hier2].[Hier2].MEMBERS //<<name of the full set
,{ //<<the set to be excluded
([Element1].[Hier1].[Hier1].&[Value1],[Element1].[Hier2].[Hier2].&[Value1]),
([Element1].[Hier1].[Hier1].&[Value2],[Element1].[Hier2].[Hier2].&[Value2]),
([Element1].[Hier1].[Hier1].&[Value3],[Element1].[Hier2].[Hier2].&[Value3]),
} ON 0
FROM [CubeName]
);
我必须执行具有以下要求的查询。
1) 我需要多个条件(AND、OR)。 2) 在某些情况下,我需要排除具有特定值的记录。
SELECT {...} ON Columns, {...} ON ROWS
FROM
(SELECT {([Element1].[Value].&[98]&[002], [Element2].Value.&[Value1]),
([Element1].[Value].&[98]&[004], [Element2].Value.&[Value2]), ([Element1].[Value].&[98]&[005], [Element2].Value.NOTIN[value1, value2]), } ON Columns
FROM [CubeName])
我已经提到了 NOTIN[value1,value2]),因为我不知道如何实现它。除了提到的那些之外,我必须获得所有值。如果有人可以提供解决方案,请告诉我。
您通常会使用函数 EXCEPT
从集合中排除一些成员:
SELECT
{...} ON 0
, {...} ON 1
FROM
(
SELECT
EXCEPT(
[Element1].[Value].[Value].MEMBERS //<<name of the full set
,{ //<<the set to be excluded
[Element1].[Value].&[98]&[002],
[Element1].[Value].&[98]&[004],
[Element1].[Value].&[98]&[005]
} ON 0
FROM [CubeName]
);
以上可以扩展为元组,但第一个参数需要是交叉连接:
SELECT
{...} ON 0
, {...} ON 1
FROM
(
SELECT
EXCEPT(
[Element1].[Hier1].[Hier1].MEMBERS
* [Element1].[Hier2].[Hier2].MEMBERS //<<name of the full set
,{ //<<the set to be excluded
([Element1].[Hier1].[Hier1].&[Value1],[Element1].[Hier2].[Hier2].&[Value1]),
([Element1].[Hier1].[Hier1].&[Value2],[Element1].[Hier2].[Hier2].&[Value2]),
([Element1].[Hier1].[Hier1].&[Value3],[Element1].[Hier2].[Hier2].&[Value3]),
} ON 0
FROM [CubeName]
);