1.11 Top/Bottom N: getting ordinal numbers of records
Find ordinal numbers of records of students whose scores 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.ptop(-2, SCORE) |
A1 Connect to the database;
A2 Query students’ scores;
A3 Get ordinal numbers of records of students whose scores rank in top 2.
Execution result:
105 |
33 |
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_SPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL