我測試了這個劇本,它拋出一個異常:
Select
{[Measures].[Quantity - Transactions]} *
{
([Tb Supplier].[City].&[B], [Tb Consumer].[City].&[A]),
([Tb Supplier].[City].&[A], [Tb Consumer].[City].&[B])
} on 0,
{[Tb Product].[Name].[Name].AllMembers} on 1
From [Cube]
你可能爲了團結兩個元創建計算成員:
SELECT
{[Measures].[Internet Sales Amount]}
*
{
{[Geography].[Geography].[Country].&[United States] * [Product].[Category].&[1]}
,{[Geography].[Geography].[Country].&[France] * [Product].[Category].&[3]}
} ON 0
,{[Date].[Calendar].[Date].&[20070801]} ON 1
FROM [Adventure Works];
此消息:
查詢(5,7)函數需要參數爲1的 參數的元組集表達式。使用了一個字符串或數字表達式。
這是因爲您需要使交叉連接的任一側具體爲一個集合 - 沒有額外的括號它不知道這一點並引發異常。
所以這是腳本的「完美」的版本:
SELECT
{[Measures].[Internet Sales Amount]}
*
{
{[Geography].[Geography].[Country].&[United States]} * {[Product].[Category].&[1]}
,{[Geography].[Geography].[Country].&[France]} * {[Product].[Category].&[3]}
} ON 0
,{[Date].[Calendar].[Date].&[20070801]} ON 1
FROM [Adventure Works];
我寧願措施移動到WHERE子句,也擺脫一些多餘的括號:
SELECT
{
{[Geography].[Geography].[Country].&[United States]}
*
{[Product].[Category].&[1]}
,
{[Geography].[Geography].[Country].&[France]}
*
{[Product].[Category].&[3]}
} ON 0
,[Date].[Calendar].[Date].&[20070801] ON 1
FROM [Adventure Works]
WHERE
[Measures].[Internet Sales Amount];
翻譯成你的立方體:
SELECT
{
{[Tb Supplier].[City].&[B]} * {[Tb Consumer].[City].&[A]}
,
{[Tb Supplier].[City].&[A]} * {[Tb Consumer].[City].&[B]}
} ON 0
,[Tb Product].[Name].[Name].ALLMEMBERS ON 1
FROM [Cube]
WHERE
[Measures].[Quantity - Transactions];
如果您還將'[Measures]。[Quantity - Transactions]'移到WHERE子句中,它會更整齊嗎? – whytheq
完美無缺。 ;) –
編輯之後是否「完美」? ;) – whytheq