您将如何订购 MDX 查询
How would you order MDX query
我无法弄清楚如何做一个简单的 "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;
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;
我无法弄清楚如何做一个简单的 "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;
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;