Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

X++ using maxof and minof in the same sql statement

Posted on by 350

Hi Everybody

How can we use at the same time minof and maxof in one sql statement ?

like doing select maxof(AccountingFate), minof(AccountingDate) from .... ?

  • Suggested answer
    Julian G Profile Picture
    Julian G 10 on at
    RE: X++ using maxof and minof in the same sql statement

    You're welcome, just let me know if you need more help..

  • Suggested answer
    JauB Profile Picture
    JauB 350 on at
    RE: X++ using maxof and minof in the same sql statement

    Thanks Julian for your suggestion

  • Suggested answer
    JauB Profile Picture
    JauB 350 on at
    RE: X++ using maxof and minof in the same sql statement

    Yes that's why I did, but wished to do it proprly .. !

    Thanks

  • Suggested answer
    Julian G Profile Picture
    Julian G 10 on at
    RE: X++ using maxof and minof in the same sql statement

    Hi,

    I have faced the same requirement and I achieved by creating a view with string computed column.

    public static server str MinAccountingDate()
    {
    tableName viewName = tableStr(View);


    return SysComputedColumn::min(SysComputedColumn::returnField(viewName, identifierStr(viewDatasourceTable) , fieldStr(viewDatasourceTable.AccountingDate)));

    }

    public static server str MaxAccountingDate()
    {
    tableName viewName = tableStr(View);


    return SysComputedColumn::max(SysComputedColumn::returnField(viewName, identifierStr(viewDatasourceTable) , fieldStr(viewDatasourceTable.AccountingDate)));

    }

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: X++ using maxof and minof in the same sql statement

    You cant, result is saved into the field, so the easiest way is to do 2 select statements 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans