General X++ Development
How do I use `sum`, `count`, `avg`, `min`, and `max` in X++?
How do I use sum, count, avg, min, and max in X++?
1 answer
Write an answerX++ supports aggregate functions directly in a select statement.
Example using sum:
SalesLine salesLine;
select sum(LineAmount) from salesLine
where salesLine.SalesId == 'SO-000001';
info(strFmt('Total: %1', salesLine.LineAmount));The supported aggregate keywords include sum, count, avg, minof, and maxof.
One thing that trips people up: the result comes back through the field you aggregated. In the example above, the total is in salesLine.LineAmount.
Know the solution?
Sign in to contribute an answer and build your community reputation.
Sign in to answer