Rank: rank

Syntax

in a Component expression within a calc clause

rank ( over ( { partitionClause } orderClause ) )

Input parameters

partitionClause

see Analytic invocation

orderClause

see Analytic invocation

Semantics for scalar operations

This operator cannot be applied to scalar values.

Input parameters type

dataset

dataset

component

component

Result type

result

dataset { measure<integer> int_var }
| component<integer>

Additional Constraints

The invocation at Data Set level is not allowed.

The Aggregate invocation is not allowed.

The windowClause of the Analytic invocation syntax is not allowed.

Behaviour

The operator returns an order number (rank) for each Data Point, starting from the number 1 and following the order specified in the orderClause. If some Data Points are in the same order according to the specified orderClause, the same order number (rank) is assigned and a gap appears in the sequence of the assigned ranks (for example, if four Data Points have the same rank 5, the following assigned rank would be 9).

For other details, see Analytic invocation.

Examples

Given the operand dataset DS_1:

Input DS_1 (see structure)

Id_1

Id_2

Id_3

Me_1

Me_2

A

XX

2000

3

1

A

XX

2001

4

9

A

XX

2002

7

5

A

XX

2003

6

8

A

YY

2000

9

3

A

YY

2001

5

4

A

YY

2002

10

2

A

YY

2003

5

7

Example 1

DS_r := DS_1 [ calc Me_2 := rank ( over ( partition by Id_1 , Id_2 order by Me_1 ) ) ];

results in (see structure):

DS_r

Id_1

Id_2

Id_3

Me_1

Me_2

A

XX

2000

3

1

A

XX

2001

4

2

A

XX

2002

7

4

A

XX

2003

6

3

A

YY

2000

9

3

A

YY

2001

5

1

A

YY

2002

10

4

A

YY

2003

5

1