4.3 Set aggregation

 

4.2 Selection as aggregation


1. The 10 lowest salaries in the company.

2. The 10 employees with the lowest salaries in the company.

SPL

A B
1 =file(“EMPLOYEE.csv”).import@tc()
2 =A1.top(10,SALARY) /The 10 lowest salaries
3 =A1.top(10;SALARY) /The 10 employees with the lowest salaries

SQL

1. The 10 lowest salaries

SELECT *
FROM (
 SELECT SALARY
 FROM EMPLOYEE
 ORDER BY SALARY)
WHERE ROWNUM <= 10;

2. The 10 employees with the lowest salaries

SELECT *
FROM (
 SELECT *
 FROM EMPLOYEE
 ORDER BY SALARY)
WHERE ROWNUM <= 10;

Python

df=pd.read_csv('../EMPLOYEE.csv')
low_salary_10=df.nsmallest(10,'SALARY')['SALARY']/#The10lowestsalaries
low_salary_10=df.nsmallest(10,'SALARY')/#The10employeeswiththelowestsalaries

4.4 Group & aggregate
Example codes for comparing SPL, SQL, and Python