I try to write a SQL-Statement in X++. It should do something like this:
SELECT
Table.field1, SUM(Table.field2) AS SumField
FROM
Table
WHERE
Table.FieldX = Something
GROUP BY
Table.Field1
ORDER BY
SumField;
The problem i have in X++ is that it orders the records before calculating the sum of them. I know that i could make a While Select
in X++ and order them by code, but that is not the way i want to do it.
Can someone tell me how i could handle this?
Sorry, but you cannot both do a sort by
and group by
in a X++ select or query.
The solution is to make a view (without the sort), then do a select on the view with the order by.