SQL在每个位置的库存数量?

时间:2014-05-23 17:43:06

标签: sql sql-server axapta dynamics-ax-2012

我们说我有一个ITEMID,我想知道每个地方的现有数量。我被告知我需要使用INVENTITEMLOCATION表和INVENTSUM表。但是,似乎没有明显的方法来加入表格以获得我需要的东西。什么表和/或键链接我提到的两个表?

    SELECT l.WMSPICKINGLOCATION
          ,s.PHYSICALINVENT
      FROM INVENTITEMLOCATION l
INNER JOIN ?????? i
        ON l.??? = i.???
INNER JOIN INVENTSUM s
        ON i.??? = s.???
     WHERE l.ITEMID = '#######'

1 个答案:

答案 0 :(得分:2)

您需要InventDim加入InventDimId

在X ++中,格式正确,它看起来像:

InventItemLocation InventItemLocation;
InventDim inventDim;
InventSum inventSum;
while select WMSPickingLocation from inventItemLocation
    join TableId from inventDim
    join PhysicalInvent from inventSum
    where inventSum.InventDimId == inventSum.InventDimId &&
          inventSum.ItemId == inventItemLocation.ItemId
{    
}    

这样可行,但不会为您提供您所声称的内容:每个位置都在手边。这就像:

InventDim inventDim;
InventSum inventSum;
while select InventLocationId from inventDim
    group InventLocationId
    join sum(PhysicalInvent) from inventSum
    group ItemId
    where inventSum.InventDimId == inventSum.InventDimId
{    
}    

在翻译为SQL时,请记住加入DataAreaIdPartitionId