我正在重新发布这个问题。我已经清理了 SQL,但仍然有一些重复的结果。我需要在每个位置找到每个 itemnum 的最新数据。这是我所拥有的:
SELECT invbalances.itemnum,
invbalances.curbal,
inventory.maxlevel,
inventory.minlevel2,
inventory.sstock,
inventory.deliverytime,
invbalances.location,
inventory.category
FROM MX7PROD.dbo.invbalances invbalances,
MX7PROD.dbo.inventory inventory
WHERE invbalances.itemnum = inventory.itemnum
AND invbalances.location = inventory.location
AND ((inventory.category<>'cstk'
And inventory.category<>'nore'
And inventory.category<>'sp')
AND (invbalances.itemnum Not Like '%n%'))
ORDER BY invbalances.itemnum