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 |
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
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