我有两个要连接在一起的查询,这会给我计算出的行总数。我遇到的问题是,尽管这些措施来自 1 个事实表,但小队名称有两个角色扮演维度。我对 MDX 非常陌生。
结果会是这样的
| Competition | Squad | Goals A | Goals B | Total (Goals A + Goals B)|
|----------------|---------|---------|---------|--------------------------|
| Premier League | Arsenal | 25 | 15 | 40 |
提前致谢。
查询1:
SELECT
([Measures].[Goals A]) ON COLUMNS,
NON EMPTY ([Dim Competition].[Hierarchy].[Competition ID],[Squad A].[Squad Name].ALLMEMBERS) ON ROWS
FROM
[FDC Star]
WHERE [Dim Competition].[Competition ID].&[1];
查询1结果:
Competition Squad Goals A
Premier League Arsenal 25
Premier League Aston Villa 8
Premier League Chelsea 22
Premier League Everton 17
Premier League Fulham 17
Premier League Liverpool 17
Premier League Manchester City 25
Premier League Manchester United 28
Premier League Newcastle United 13
Premier League Norwich City 13
Premier League Queens Park Rangers 8
Premier League Reading 15
Premier League Southampton 15
Premier League Stoke City 14
Premier League Sunderland 11
Premier League Swansea City 19
Premier League Tottenham Hotspur 17
Premier League West Bromwich Albion 17
Premier League West Ham United 19
查询2:
SELECT
([Measures].[Goals B]) ON COLUMNS,
NON EMPTY ([Dim Competition].[Hierarchy].[Competition ID],[Squad B].[Squad Name].ALLMEMBERS) ON ROWS
FROM
[FDC Star]
WHERE [Dim Competition].[Competition ID].&[1];
查询2结果:
Competition Squad Goals B
Premier League Arsenal 15
Premier League Aston Villa 9
Premier League Chelsea 17
Premier League Everton 18
Premier League Fulham 15
Premier League Liverpool 17
Premier League Manchester City 16
Premier League Manchester United 26
Premier League Newcastle United 14
Premier League Norwich City 11
Premier League Queens Park Rangers 9
Premier League Reading 8
Premier League Southampton 12
Premier League Stoke City 7
Premier League Sunderland 10
Premier League Swansea City 12
Premier League Tottenham Hotspur 22
Premier League West Bromwich Albion 12
Premier League West Ham United 5