我有一个名为" tableOne"的数据库表。该表与立方体连接。
以下SQL选择查询
select row_id, row_group_id, col_group_id, measure_col from tableOne where
(row_group_id in (select row_group_id from tableOne a where row_id in ('R0020', 'R0030') and col_id = 'C0050')
or col_group_id in (select col_group_id from tableOne a where row_id in ('R0020', 'R0030') and col_id ='C0050'));
必须将转换为MDX查询。
请注意:
我正在使用Mondrian,我不知道如何将子选择转换为MDX查询。
编辑:
这是我到目前为止所得到的:
SELECT
{
[Measures].[measure_col]
}
ON COLUMNS,
non empty(
CrossJoin([ROW].[ROW].Members
,CrossJoin([COL_GROUP].[COL_GROUP].Members
,[ROW_GROUP].[ROW_GROUP].Members
)))
ON ROWS
FROM [tableOne]
WHERE (
[COL].[COL].[C0050]
)
除了我已经告诉过你的内容之外,不能告诉你关于立方体的任何其他信息。
答案 0 :(得分:0)
首先,我建议您将SQL重写为:
select row_id, row_group_id, col_group_id, measure_col
from tableOne a
where
exists(
select *
from tableOne b
where
row_id in ('R0020', 'R0030') and
col_id = 'C0050' and
(
a.row_group_id = b.row_group_id OR
a.col_group_id = b.col_group_id
)
)
它应该从您的计划中删除一个扫描。现在是MDX的一部分。
如果您要在计算的度量中使用某些内容,最好是在SQL中执行此操作。
不确定此MDX是否会返回您想要的输出。
WITH
SET mySet
AS
NONEMPTY (
(
[COL_GROUP].[COL_GROUP].Members,
[ROW_GROUP].[ROW_GROUP].Members
),
(
{[ROW].[ROW].[R0020],[ROW].[ROW].[R0030]},
[COL].[COL].[C0050],
[Measures].[measure_col]
)
)
SELECT
{
[Measures].[measure_col]
}
ON COLUMNS,
NON EMPTY
CROSSJOIN(
[ROW].[ROW].MEMBERS,
mySet
)
ON ROWS
FROM [tableOne]
mySet
应该为您提供COL_GROUP
和ROW_GROUP
的所有组合,其值为ROW
R0020和R0030以及COL
C0050。