rank()

Read(912) Label: iterative loop, number records,

Description:

Perform an iterative calculation in a loop function to number records according to values of a specific field.

Syntax:

rank(F;Gi,…)

Note:

The function performs a loop operation to number records from 1 according to values of Gi field. With the same Gi field value, records having same F field value will be given same ordinal number. When the value of F field changes, the ordinal number for the corresponding record is the previous ordinal number plus the number of the records with that ordinal number. When the value of Gi field changes, start a new round of the numbering process. Note that the function does not sort records.

Parameter:

F

Field name

Gi

Field name

Return value:

Integer

Example:

 

A

 

1

=demo.query("select  SUBJECT,STUDENTID,SCORE from SCORES where CLASS='Class one' order by SUBJECT,SCORE desc")

Get score information of students in class one and sort result by SUBJECT in ascending order and by SCORE in descending order.

2

=A1.derive(rank(SCORE;SUBJECT): RANKING)

Get ranking of scores for each subject – same rank for same score and a tied result takes up a rank, and store result ranks under RANKING field.