2.16 Grouping: calculate median
Calculate the median salary in each department based on the following salary table.
ID | NAME | DEPT | SALARY |
---|---|---|---|
1 | Rebecca | R&D | 7000 |
2 | Ashley | Finance | 11000 |
3 | Rachel | Sales | 9000 |
4 | Emily | HR | 7000 |
5 | Ashley | R&D | 16000 |
… | … | … | … |
SPL script:
A | |
---|---|
1 | =T(“salary.xlsx”) |
2 | =A1.groups(DEPT;median(,SALARY):MedianSalary) |
Execution result:
DEPT | MedianSalary |
---|---|
Administration | 9500.0 |
Finance | 7000.0 |
HR | 7000 |
Marketing | 7000 |
Production | 6500 |
… | … |
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