4.2 Selection as aggregation

 

4.1 Basic aggregation


Find the information of the employee with the maximu salary in the company.

SPL

A B
1 =file(“EMPLOYEE.csv”).import@tc()
2 =A1.maxp(SALARY) /One member with the maximum salary
3 =A1.maxp@a(SALARY) /All members with the maximum salary

SQL

1. One member with the maximum salary

SELECT *
FROM EMPLOYEE
ORDER BY SALARY DESC
FETCH FIRST 1 ROWS ONLY;

2. All members with the maximum salary

SELECT * FROM EMPLOYEE
WHERE SALARY = (SELECT MAX(SALARY) FROM EMPLOYEE);

Python

df = pd.read_csv('../EMPLOYEE.csv')
max_salary_emp = df.nlargest(1,'SALARY') /#One member with the maximum salary
max_salary_emp_all = df.nlargest(1,'SALARY',keep='all') /#All members with the maximum salary

4.3 Set aggregation
Example codes for comparing SPL, SQL, and Python