General X++ Development
How do I use `group by` in X++?
How do I use group by in X++?
1 answer
Write an answerUse group by with aggregate functions when you want one result per grouped value.
SalesLine salesLine;
while select ItemId, sum(LineAmount) from salesLine
group by ItemId
{
info(strFmt('%1 - %2', salesLine.ItemId, salesLine.LineAmount));
}The aggregate result is returned through the field buffer you aggregated. Any non-aggregate field you select needs to be part of the grouping.
Know the solution?
Sign in to contribute an answer and build your community reputation.
Sign in to answer