Oracle9i OLAP Services Developer's Guide to the Oracle OLAP API Release 1 (9.0.1) Part Number A88756-01 |
|
Selecting Data, 4 of 5
When a Source
is sorted according to some attribute (or attributes), then the position of the elements of the Source
represents a kind of ranking -- the so-called unique ranking. Finding the position of an element is discussed in "Finding the position of elements".
There are many other types of rankings that are not unique and that are called variant rankings. These are discussed in "Ranking elements in different ways".
The position
method returns a Source
that represents the position of any given element in the original Source
. The new Source
has the type of Integer and has the original Source
as an input. The position
method returns a Source
that represents the position of any given element of the base Source
. If the base Source
is sorted according to some attribute (or attributes), then the position represents a kind of ranking - the so called unique ranking.
You can also use the shortcut methods described in the following table to find elements based on their position in a Source
object or to find the position of elements with the specified value or values.
Assume that there is a Source
named products
whose elements are the unique identifiers of products. To create a new Source
whose elements are the positions of the elements of products
, issue the following code.
Source productsPosition = products.position();
A tabular representation of productsPosition
showing the position of the elements in products
is shown below. Note that the position()
method is one based.
Input |
Element |
---|---|
|
Integer |
395 |
1 |
400 |
2 |
405 |
3 |
415 |
4 |
420 |
5 |
425 |
6 |
... |
|
Assume that there is a Source
named unitsSoldByCountry
(shown below) that has an input of products
, an output of countries
, and elements whose values are the total number of units for each product sold for each country.
Input |
Output |
Element |
Position |
---|---|---|---|
|
|
Integer |
|
395 |
Australia |
500 |
1 |
395 |
United States |
800 |
2 |
... |
... |
|
... |
49780 |
Australia |
10000 |
1 |
49780 |
United States |
50 |
2 |
49780 |
... |
|
... |
To create a new Source
named positionUnitsSoldByCountry
whose elements are the positions of the elements of unitsSoldByCountry
, issue the following code.
Source positionUnitsSoldByCountry = unitsSoldByCountry.position();
The following table provides example code for ranking elements in different ways where the Source
(named base
) whose elements you want to rank has two inputs named input1
and input2
.
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|