Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

MS SQL

Posted May 10, 2004

MDX Essentials: Basic Set Functions: Subset Functions: The Head() Function - Page 4

By William Pearson

Handling of Numeric Value

Next, let's explore the handling of omitted numeric values, among the other "default" treatments that the Head() function doles out. We can see these treatments in action by simulating some quick scenarios.

1. Within the query we have saved as MDX19-1, replace the top comment line of the query with the following:

-- MDX019-2, Use of Head() Function - Omitted Numeric Expression

2. Save the query as MDX19-2, to prevent damaging MDX19-1.

3. Remove the comma (",") and numeral 3 from the following line of the query:

              {Head([Time].[1998].Children, 3)} ON COLUMNS,

The Query pane appears as shown in Illustration 2.

Click for larger image

Illustration 2: The Query with Omitted Numerical Expression

4. Execute the query by clicking the Run Query button in the toolbar.

The Results pane is populated, and the dataset shown in Illustration 3 appears.


Illustration 3: Result Dataset - Head() Function with Omitted Numerical Expression

5. Re-save the file as MDX19-2.

6. Leave the query open for the next step.

We see that the "default" value assumed by the function, in the absence of a specified numeric expression, is 1. Q1 only is returned, on the column axis, as a result.

7. Within the query we have saved as MDX19-2, replace the top comment line of the query with the following:

-- MDX019-3, Use of Head() Function -Numeric Expression < 1

8. Save the query as MDX19-3.

9. Add a comma (",") after .Children, then a space, and then the numeral -1, into the following line of the query:

              {Head([Time].[1998].Children)} ON COLUMNS,

The Query pane appears as shown in Illustration 4, with the inserted coding circled in red.


Illustration 4: The Query with Numerical Expression Less Than 1



MS SQL Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM


















Thanks for your registration, follow us on our social networks to keep up-to-date