SQL中用于MDX查询的分组依据的等效项

时间:2018-11-28 15:26:13

标签: sql mdx

我有一个SQL查询,如下所示:

SELECT "Supplier City", "Consumer City",SUM([Number of Transactions]) AS "Number of Transactions"
FROM Tb_Transactions_Cube 
WHERE "Supplier Name" IS NOT NULL
    AND "Supplier City" IS NOT NULL
    AND "Supplier State" IS NOT NULL    
    AND "Consumer Name" IS NOT NULL    
    AND "Consumer City" IS NOT NULL    
    AND "Consumer State" IS NOT NULL    
    AND "Product Name" IS NULL
GROUP BY "Supplier City", "Consumer City"

此查询返回供应商-城市-消费者-城市对之间的交易数量。我正在尝试在MDX中创建此查询的等效项,但我似乎对如何将组应用于MDX查询感到困惑。到目前为止,我在mdx中拥有的内容如下:

SELECT NON EMPTY { 
                    SUM([Measures].[Tb Transactions Count]) AS "Number of Transactions" } ON COLUMNS,        
        NON EMPTY {  
                    [Tb Supplier].[City].[City].ALLMEMBERS,
                    [Tb Consumer].[City].[City].ALLMEMBERS } ON ROWS
FROM [Table]

我是mdx的新手,因此不确定这是否是正确的方法以及如何将group by应用于当前查询。任何帮助或见解将非常有帮助。

1 个答案:

答案 0 :(得分:1)

您的查询将获得您期望的结果。我不知道在MDX中进行此聚合的任何其他方式。