O'Reilly logo

Microsoft® SQL Server® 2008 MDX Step by Step by C Ryan Clay Bryan C Smith and Hitachi Consulting

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6 Quick Reference

To

Do this

Order a set by an expression

Use the Order function to sort the set. For example, the following query orders all products by reseller sales in descending order:

SELECT
  {([Measures].[Reseller Sales Amount])} ON COLUMNS,
  Order(
    {[Product].[Product].[Product].Members},
    ([Measures].[Reseller Sales Amount]),
    DESC
    ) ON ROWS
FROM [Step-by-Step]

Use the ASC or DESC flag to perform a hierarchal sort in ascending or descending order, and use the BASC or BDESC flag to sort across hierarchies in ascending or descending order, respectively.

Restore the order of a set to its natural order

Use the Hierarchize function to sort a set by its natural order. For example:

SELECT {([Measures].[Reseller Sales Amount])} ON COLUMNS, Hierarchize( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required