我无法弄清楚如何做一个简单的“order by”子句。
以下是我的查询 - 如何按Service Name
然后按Adjusted Incidents
订购?
SELECT
{[Measures].[Adjusted Incidents]} ON COLUMNS
,NON EMPTY
{
[Completed Inspections].[Service Name].[Service Name].ALLMEMBERS
*
[Inspected Items].[Item Name].[Item Name].ALLMEMBERS
}
DIMENSION PROPERTIES MEMBER_CAPTION ON ROWS
FROM
(
SELECT
{
[Completed Inspections].[Customer Id].&[DRHOD]
,[Completed Inspections].[Customer Id].&[EMHST]
,[Completed Inspections].[Customer Id].&[EXHOU]
,[Completed Inspections].[Customer Id].&[ETRAD]
} ON COLUMNS
FROM [Inspections]
)
WHERE
(
[Calendar].[Month].&[2015-05-01T00:00:00]
,[Completed Inspections].[Is Reinspection].&[False]
)
CELL PROPERTIES VALUE;
答案 0 :(得分:1)
mdx
中没有与sql
类似的订单条款。
您需要将函数ORDER
应用于您要订购的任何集合。以下是msdn
定义:
https://msdn.microsoft.com/en-us/library/ms145587.aspx
在mdx
中嵌套订单并不是那么简单 - 订单的内部应用程序是您要应用的订单,第二个外部嵌套是您首先要应用的订单:
SELECT
{[Measures].[Adjusted Incidents]} ON COLUMNS
,NON EMPTY
Order
(
Order
(
{
[Completed Inspections].[Service Name].[Service Name].ALLMEMBERS
*
[Inspected Items].[Item Name].[Item Name].ALLMEMBERS
}
,[Measures].[Adjusted Incidents]
,BDESC //<<you have 4 choices here BDESC, BASC, DESC, or ASC
)
,[Completed Inspections].[Service Name].CurrentMember.Member_Caption
,BDESC //<<you have 4 choices here BDESC, BASC, DESC, or ASC
)
DIMENSION PROPERTIES MEMBER_CAPTION ON ROWS
FROM
(
SELECT
{
[Completed Inspections].[Customer Id].&[DRHOD]
,[Completed Inspections].[Customer Id].&[EMHST]
,[Completed Inspections].[Customer Id].&[EXHOU]
,[Completed Inspections].[Customer Id].&[ETRAD]
} ON COLUMNS
FROM [Inspections]
)
WHERE
(
[Calendar].[Month].&[2015-05-01T00:00:00]
,[Completed Inspections].[Is Reinspection].&[False]
)
CELL PROPERTIES VALUE;