• subscribe
January 05, 2000 11:03 AM

January MDX Puzzle Solution Revealed

SQL Server Pro
InstantDoc ID #7931
Downloads
7931.zip

Last month's question asked: Using the FoodMart Sales cube, what are the unit sales of the states in the United States for each of the most recent 3 months that have data? The query in Listing A is the answer.

Multiple solutions will work, but I chose calculated sets because this solution demonstrates the use of sets and how to index into a set to return a particular set item. The first set, [Recent Months], uses the filter function to collect all the months that have data. The second set, [Recent Month], uses the item property to index into the first set to retrieve the most recent month. [Recent Month] is a set containing a single month.

This query displays the most recent three months in reverse order on the columns. It uses the item property to retrieve the first item in the [Recent Month] set. Then it uses the Lag function to retrieve the adjacent months.



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
  • SP1?
    I know there is a SP1 for SQL 2008 R2 available....and there is a "feature pack" as well... ...
  • SQL database mirroring
    I have SQL Server 2008 R2 Enterprise 64bit on Windows 2008 R2 Enterprise 64bit.  Each SQL Server has...
  • Dell Compellent Disk Drive
    Does anybody has experience with Dell Compellent Disk Drive? Basically, this system manages all disk...
  • Sql server performance tuning
    I need to find a tool that help me to optimize sql server,queries,improve the performance and solve ...