我有两个表,如下图所示,并希望将一个联合查询组合起来,但只返回任何项目的最新日期。
答案 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]