1.10 Top/Bottom N: getting values

 

Find scores of students who rank in top 2 based on the following Scores table.

STUDENTID SCORE
1 84
2 77
3 69
4 81
5 80

SPL script:

A
1 =connect(“db”)
2 =A1.query@x(“select * from Scores”)
3 =A2.top(-2, SCORE)

A1 Connect to the database;
A2 Query students’ scores;
A3 Get scores of students who rank in top 2. Note: The comma means returning the two values ranking in top 2.

Execution result:

97
96