将MDX查询转换为SQL查询

时间:2019-01-25 08:34:55

标签: sql-server tsql mdx

我无法将MDX查询转换为SQL查询。谁能帮助我找到任何在线转换器,或者转换下面的代码?我找不到一个。

由于我是MDX Query的新手,我发现很难转换为SQL Query,并且想知道是否有一些资源可以更轻松地实现它?

WITH
SET [~ROWS_RRE Information_Reporting Period] AS
    {[RRE Information].[Reporting Period].&[7]}
SET [~ROWS_Basic Claim Info_Data Provider] AS
    {[Basic Claim Info].[Data Provider].[Data Provider].Members}
SET [~ROWS_Claim Information Detail_RRE ID] AS
    {[Claim Information Detail].[RRE ID].[RRE ID].Members}
SET [~ROWS_Claim Information Detail_RRE Name] AS
    {[Claim Information Detail].[RRE Name].[RRE Name].Members}
SET [~ROWS_RRE Information_Reporting Agent] AS
    {[RRE Information].[Reporting Agent].&[Exam Works], [RRE Information].[Reporting Agent].&[Exam Works/ASSIGNED], [RRE Information].[Reporting Agent].&[Life Care Planning Solutions, LLC], [RRE Information].[Reporting Agent].&[MIRService], [RRE Information].[Reporting Agent].&[PMSI], [RRE Information].[Reporting Agent].&[PMSI Settlement Solutions], [RRE Information].[Reporting Agent].&[UNKNOWN], [RRE Information].[Reporting Agent].&[ISO]}

SELECT
NON EMPTY CrossJoin({[Basic Claim Info].[Claim Status].&[MB Pending], [Basic Claim Info].[Claim Status].&[Deleted], [Basic Claim Info].[Claim Status].&[MB Accepted], [Basic Claim Info].[Claim Status].&[MB Error], [Basic Claim Info].[Claim Status].&[MB Rejected], [Basic Claim Info].[Claim Status].&[MB Submit], [Basic Claim Info].[Claim Status].&[Q Error], [Basic Claim Info].[Claim Status].&[Q Pending], [Basic Claim Info].[Claim Status].&[Q Submitted], [Basic Claim Info].[Claim Status].&[Stopped], [Basic Claim Info].[Claim Status].[All].UNKNOWNMEMBER, [Basic Claim Info].[Claim Status].&[Not Reportable]}, {[Measures].[Claim Count]}) ON COLUMNS,
NON EMPTY ([~ROWS_RRE Information_Reporting Period]  *  [~ROWS_Basic Claim Info_Data Provider]  *  [~ROWS_Claim Information Detail_RRE ID]  *  [~ROWS_Claim Information Detail_RRE Name]  *  [~ROWS_RRE Information_Reporting Agent]) ON ROWS
FROM [MA Reporter NG]]

1 个答案:

答案 0 :(得分:2)

MDX和SQL是两种不同的语言,SQL不适用于OLAP,而MDX不适用于事务性数据库。

但是,基于您的多维数据集(SSAS项目)将在事务数据库中具有基础维模型(星型架构)的事实。通常,多维数据集中的维度和事实针对每个维度和事实组都有一个基础表。基于这个假设,我已经翻译了您的查询,但是结果只是一个草图,可以帮助您弄清楚该怎么做。

select a.[Reporting Period],b.[Data Provider],c.[RRE ID],c.[RRE Name],a.[Reporting Agent],b.[Claim Status],count(distinct f.ClaimID)
from 
YourFact f //This will be your fact table having keys of all the dimensions 
inner join 
[RRE Information] a 
on relevantkeys //Join with fact table using this dimensions key
inner join 
[Basic Claim Info] b 
on relevantkeys
inner join 
[Claim Information Detail] c
on relevantkeys
where a.[Reporting Period]=7 and a.[Reporting Agent] in (this list mentioned in ~ROWS_RRE Information_Reporting Agent)
group by 
a.[Reporting Period],b.[Data Provider],c.[RRE ID],c.[RRE Name],a.[Reporting Agent],b.[Claim Status]