如何创建一个UNION查询,该查询将返回项目库存的最新日期?

时间:2018-03-17 01:36:03

标签: ms-access

我有两个表,如下图所示,并希望将一个联合查询组合起来,但只返回任何项目的最新日期。 Tables and results

1 个答案:

答案 0 :(得分:1)

试试这个:

Select [Part Number], [Rack Number], [Row Number], Max([Date Scanned]) As [Last Scanned]
From 
    (Select [Part Number], [Rack Number], [Row Number], [Date Scanned]
    From Table1
    Union
    Select [Part Number], [Rack Number], [Row Number], [Date Scanned]
    From Table2)
Group By
    [Part Number], [Rack Number], [Row Number]