Oracle9i OLAP Developer's Guide to the OLAP DML
Release 2 (9.2)

Part Number A95298-01
 Home Book List Contents Index Master Index Feedback

Selecting Data, 6 of 13

## Limiting to the Values of a Related Dimension

You can use the `LIMIT` command to limit a dimension to the values of one or more related dimensions. The simplified syntax for using the `LIMIT` command in this way is shown below:

```LIMIT dimension TO reldim [reldim-val]

```

The `reldim` argument is the name of a relation or a dimension that is related to the dimension being limited. Using a relation name allows you to choose which relation is used when there is more than one.

The `reldim-val` argument is a list of values of the related dimension, and not the dimension being limited. If this argument is present in a `LIMIT` command, then status is obtained by selecting the values of the dimension being limited, which are related to related values. If reldim-val is omitted, then the current status of `reldim` is used.

#### Example 6-4 Limiting Using a Related Dimension

The following command limits `district` to `BOSTON` and `ATLANTA`, which are in the `EAST` region.

```LIMIT district TO region 'EAST'

```

This command limits `product` to `SPORTSWEAR` and `FOOTWEAR`, which are in the division that appears last in the list of `DIVISION` values.

```LIMIT product TO division LAST 1
```

### How Limiting to a Related Dimension Determines Status

When you limit a dimension to a related dimension, the current status list is created in a two-step process:

1. The values in the dimension current status list are arranged in the order of the values of the related dimension.
2. If there is more than one value of the dimension for any value of the related dimension, then the values in the dimension current status list are arranged in the order of their default status list.

### Suppressing the Sort When Limiting to a Related Dimension

The `LIMIT.SORTREL` option controls whether or not a sort is done when you limit a dimension to a related dimension. You can suppress the sort that occurs when you limit a dimension to a related dimension by setting `LIMIT.SORTREL` to `no`. This can significantly improve performance when the dimension you are limiting is large.

 Note: When `LIMIT.SORTREL` is `NO`, printed output of a dimension may not appear in logical order.