CustTable custTable;
while select count(RecId), CustGroup from custTable
group by CustGroup
order by custTable.RecId desc
{
info(strFmt("%2 - %1", custTable.RecId, custTable.CustGroup));
}
Hello, I've encountered interesting case in AX 2012. Basically what I am trying to do is to sort my data by the amount that count(RecId) returns when it is grouped by CustGroup. Well, "order by custTable.count(RecId) or any other variation of that arises syntax error. Do you have any idea, what to do with this?
I was suggested to use View, but even with View, I couldn't find the solution which lets me order by the expression of aggregated function (count in this case).
*This post is locked for comments
That settles everything. I had been trying to put the whole logic either in select statement or in View, together they work perfectly. Thanks for your effort!
Hi!
I try use a view and it work
ustTable custTable; CustTestView CustTestView; while select count(RecId), CustGroup from custTable group by CustGroup order by custTable.RecId desc { info(strFmt("%2 - %1", custTable.RecId, custTable.CustGroup)); } info('View'); while select CustTestView order by CountOfRecId desc { info(strFmt("%2 - %1", CustTestView.CountOfRecId, CustTestView.CustGroup)); }
André Arnaud de Cal...
292,074
Super User 2025 Season 1
Martin Dráb
230,900
Most Valuable Professional
nmaenpaa
101,156