Nested notExists joins X++ (Dynamics AX3.0)

馋奶兔 提交于 2019-12-03 22:11:45

The short answer: no!

In your example, you could reformulate using inner join:

select sum(qty) from inventTrans
    index hint TransTypeIdx
    where inventTrans.ItemId        == itemId
       && inventTrans.TransType     == InventTransType::Sales
       && inventTrans.InventDimId   == inventDimId
    join salesTable
    where salesTable.SalesId        == inventTrans.TransRefId
       && salesTable.Extraordinary  == NoYes::No;
    notExists join custTable
    where custTable.AccountNum      == inventTrans.CustVendAC
       && custTable.CustGroup       == custGroupId

It should work provided you do not delete sales orders when invoicing.

You're probably not waiting for an answer anymore, but on Ax 2012 I still experienced the same problem.

Found another solution (aside from using a SQL Statement), not the most performant one, but it works:

  • Create a query: select * from inventTrans notexists join CustTable ....
  • Create a view based on that query
  • do the same for the salesTable
  • change your select statement as follows:

    select inventTrans

    ...

    exists join myCustView

    where myCustView.InventTransRecId == inventTrans.RecId

    exists join mySalesView

    where ...

Hope this helps,

T

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!