• subscribe
June 01, 2001 12:00 AM

May MDX Puzzle Solution Revealed

SQL Server Pro
InstantDoc ID #20988

Using the FoodMart 2000 Sales database, determine which promotion caused the most unique customers to purchase products.

WITH MEMBER [Measures].[Customers Per Promotion] AS 'Count( 
{[Unit Sales]} * [Customers].[Name].Members, ExcludeEmpty )'
SELECT { [Customers Per Promotion] } on COLUMNS,
 Order(Except([Promotions].[Promotion Name].Members, 
 {[Promotions].[All Promotions].[No
 Promotion]}) , [Customers Per Promotion], DESC ) on ROWS
FROM Sales

This puzzle was a quiz on the distinct count technique covered in "Distinct Count Queries," May 2001. The [Customers Per Promotion] measure is a count of the distinct customers with non-empty unit sales for the currently selected promotion. The MDX query evaluates [Customers Per Promotion] for each promotion and returns the ordered list of promotions.



ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here