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.
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