dbTalk Databases Forums  

Equivalent SQL exists translation in MDX

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Equivalent SQL exists translation in MDX in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
christian
 
Posts: n/a

Default Equivalent SQL exists translation in MDX - 04-10-2006 , 01:23 AM






Hello,
I've a problem writing a MDX statement. The statement should sum up the
turnover for a customer only if the order contains at least two items
with different promotion types.

In SQL, this statement is rather easy. Using the Adventure Works DW
database the SQL statement would be something like

select f1.customerkey, sum(extendedamount)
from factinternetsales f1
where exists (
select *
from factinternetsales f2
where f1.salesordernumber = f2.salesordernumber
and f1.promotionkey <> f2.promotionkey
)
group by f1.customerkey

But how to tanslate the exists statement in MDX using the Adventure
Works cube? Please let me know any suggestions.
thanks


Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default Re: Equivalent SQL exists translation in MDX - 04-11-2006 , 11:57 AM






Here's an equivalent MDX query, based on filtering the [Internet Sales
Order Details] fact dimension. Unfortunately, performance is poor (3+
hours on my server), since the benefits of OLAP pre-aggregation are
lost.

If you knew ahead of time that you needed to slice data by number of
promotions per sales order, a dimension or attribute could be created
and performance would be better.

Quote:
select {[Measures].[Internet Extended Amount]} on 0,
Non Empty [Customer].[Customer].[Customer].Members on 1
from [Adventure Works]
where Filter([Internet Sales Order Details].[Internet Sales
Orders].[Order Number].Members,
Exists([Promotion].[Promotion].[Promotion].Members,, "Internet
Sales").Count > 1)
Quote:


- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


Reply With Quote
  #3  
Old   
christian
 
Posts: n/a

Default Re: Equivalent SQL exists translation in MDX - 04-13-2006 , 08:34 AM



Hello Deepak,
that's the statement I was looking for. I'll consider introducing a new
dimension.
Thanks,
Christian


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.