2.6 冗余分组字段
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 唯一决定了 EmployeeName 的值,只按 EmployeeID 分组即可,EmployeeName 写到后面,默认自动取第一个值,计算性能更优