1
我想写一个查询,显示TOP 4 Internet销售额根据年和产品。并且,与此同时,我试图显示TOP 1经销商销售额根据年仅。MDX:Top X由两个分组和Top Y(X> Y)组成两组
Year Product Internet Sales Amount Reseller Sales Amount
CY 2015 Road-150 Red, 48 $153,215 $25,021
CY 2015 Road-150 Red, 68 $101,215 $25,021
CY 2015 Road-150 Red, 22 $93,215 $25,021
CY 2015 Road-250 Red, 52 $90,215 $25,021
CY 2014 Road-150 Red, 100 $202,215 $60,021
CY 2014 Road-220 Black, 90 $180,101 $60,021
CY 2014 Road-65 Blue, 28 $139,465 $60,021
CY 2014 Road-86 Red, 33 $100,001 $60,021
我写了下面的查询,实现4强Internet销售金额按年及产品,但无法弄清楚如何将一个小节添加到结果集。
WITH
SET [TopSalesbyYearAndProd] AS
Generate
(
[Date].[Calendar Year].[Calendar Year].MEMBERS
,TopCount
(
[Date].[Calendar Year].CurrentMember
*
[Product].[Product].[Product].MEMBERS
,4
,[Measures].[Internet Sales Amount]
)
)
SELECT
{[Measures].[Internet Sales Amount]} ON 0
,NON EMPTY
{[TopSalesbyYearAndProd]} ON 1
FROM [Adventure Works];
谢谢whytheq。一旦你知道这个优雅的版本,请张贴。 –
@sagarpant - DITTO:如果你在我之前找到它,请发布! – whytheq