2.6 When there is a redundant grouping field

 

SQL

SELECT EmployeeID, EmployeeName,sum(Amount) AS Amount
FROM Orders
WHERE OrderDate>='2022-01-01'
GROUP BY EmployeeID, EmployeeName
ORDER BY EmployeeID

SPL

A
1 >st=date(“2022-01-01”), start=days@o(st)
2 =file(“Orders.ctx”).open().cursor@x(EmployeeID, EmployeeName,Amount;OrderDate>start)
3 =A2.groups(EmployeeID; EmployeeName,sum(Amount):Amount)

A3 EmployeeID identifies EmployeeName value uniquely, so it is enough to perform grouping only by EmployeeID while writing EmployeeName directly after it, which by default is assigned the first value automatically. This helps achieve higher performance.