Trivial: by in group by is optional

August 4, 2010 at 18:11
filed under Dynamics AX
Tagged , , , ,

Here is something I did not know: apparently, the ‘by’ in ‘group by’ is optional.

The following job compiles just fine, and outputs the correct result:

static void KlForGroupBy(Args _args)
{
    InventTable inventTable;
    ;
   
    while select inventTable
    group by ItemGroupId
    {
        info(inventTable.ItemGroupId);
    }
   
    info('------');
   
    while select inventTable
    group ItemGroupId // without by
    {
        info(inventTable.ItemGroupId);
    }
}

It looks funny though :-).

4 comments

RSS / trackback

  1. Luegisdorf

    .. and it does for the ‘order by’ …

  2. Klaas Deforche

    Hehe, yes, it is optional for ‘order by’ too. :-)

  3. j.a.estevan

    a bug or an “undocumented feature”? (difference is sutile :P)

  4. Daniel

    mayday mayday!! Best Practices are down.

respond