Comparison Operators

You use comparison operators with scalar data. You can use comparison operators in any Multidimensional Expressions (MDX) expression.

To check for a condition, you can also use comparison operators in MDX statements and functions, such as the MDX IIf function. However, if you use comparison operators to check for a condition, make sure that you have appropriate permissions before trying to change data based upon that condition. Anyone that has access to the actual data and can query that data can use comparison operators in additional queries. But this access does not mean that these individuals have or should have the appropriate permissions to change data. Also, to maintain data integrity, limit the number of people that can query and change data.

Comparison operators evaluate to a Boolean data type, returning TRUE or FALSE based on the outcome of the tested condition.

MDX supports the comparison operators listed in the following table.

Operator Description

= (Equal To)

For non-null arguments, returns TRUE if the left argument is equal to the right argument; otherwise, FALSE.

If either or both arguments evaluate to a null value, the operator returns a null value, unless the comparison 0=null is made, in which case the Boolean contains TRUE.

<> (Not Equal To)

For non-null arguments, returns TRUE if the left argument is not equal to the right argument; otherwise, FALSE.

If either or both arguments evaluate to a null value, the operator returns a null value.

> (Greater Than)

For non-null arguments, returns TRUE if the left argument has a value that is greater than the right argument; otherwise, FALSE.

If either or both arguments evaluate to a null value, the operator returns a null value.

>= (Greater Than or Equal To)

For non-null arguments, returns TRUE if the left argument has a value that is higher than or equal to the right argument; otherwise, FALSE.

If either or both arguments evaluate to a null value, the operator returns a null value.

< (Less Than)

For non-null arguments, returns TRUE if the left argument has a value that is less than than the right argument; otherwise, FALSE.

If either or both arguments evaluate to a null value, the operator returns a null value.

<= (Less Than or Equal To)

For non-null arguments, returns TRUE if the left argument has a value that is lower than or equal to the right argument; otherwise, FALSE.

If either or both arguments evaluate to a null value, the operator returns a null value.

See Also

Reference

MDX Operator Reference (MDX)

Concepts

Operators (MDX Syntax)

Help and Information

Getting SQL Server 2005 Assistance