Во-первых, мои знания по MDX очень ограничены
По сути, у меня есть 2 запроса;один с продажами штаб-квартиры по отделам и один с продажами складских помещений по отделам.Я хотел бы возвратить результаты продаж отделов складского помещения, а затем отдел продаж штаб-квартиры за один раз.
Заранее спасибо.
В SQL запрос должен бытьпримерно так:
SELECT StockRoom.Code, StockRoom.Sales, StockRoom.Department, StockRoom.HQ
, (SELECT SUM(HQ.Sales)
FROM StockRoom HQ
WHERE HQ.Department = StockRoom.Department
AND HQ.HQ = StockRoom.HQ) as HQSales
FROM StockRoom StockRoom
WHERE Week = 12
AND Year = 2011
AND Code = 'C001'
РЕДАКТИРОВАТЬ: я работаю над кубом OLAP с использованием служб отчетов SQL Server (Visual Studio 2k8R2).Вот мой текущий запрос MDX:
SELECT NON EMPTY { [Measures].[CATTC], [Measures].[CATTC N-1], [Measures].[PROG] }
ON COLUMNS
, NON EMPTY { ([Stock room].[Stock room class Enseigne].[Stock room class Enseigne].ALLMEMBERS * [Stock room].[Stock room geographical dynamic hierarchy].[Stock room].ALLMEMBERS * [Product].[Product Hierarchy].[Product main class level 3].ALLMEMBERS ) }
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM ( SELECT ( STRTOSET(@TimecalendarTimecalendarweekofyear, CONSTRAINED) )
ON COLUMNS FROM ( SELECT ( STRTOSET(@TimecalendarTimecalendaryear, CONSTRAINED) )
ON COLUMNS FROM ( SELECT ( STRTOSET(@StockroomStockroomcode, CONSTRAINED) )
ON COLUMNS FROM [CustomNextTest])))
WHERE ( IIF( STRTOSET(@StockroomStockroomcode, CONSTRAINED).Count = 1, STRTOSET(@StockroomStockroomcode, CONSTRAINED), [Stock room].[Stock room code].currentmember )
, IIF( STRTOSET(@TimecalendarTimecalendaryear, CONSTRAINED).Count = 1, STRTOSET(@TimecalendarTimecalendaryear, CONSTRAINED), [Time calendar].[Time calendar year].currentmember )
, IIF( STRTOSET(@TimecalendarTimecalendarweekofyear, CONSTRAINED).Count = 1, STRTOSET(@TimecalendarTimecalendarweekofyear, CONSTRAINED), [Time calendar].[Time calendar week of year].currentmember ) )
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS