我正在建立一个查询,希望提取最新的发票日期以及单价和购买因子。
SELECT
pn.Part_Number AS Part_Number,
pn.Purchasing_Factor AS Purchasing_Factor,
MAX(ph.PO_Date) AS PO_Date,
pd.Unit_Cost AS Unit_Cost
FROM dbo.PO_Detail pd
LEFT OUTER JOIN dbo.PO_Header ph ON pd.PO_Header_ID = ph.PO_Header_ID
LEFT OUTER JOIN dbo.Part_Number pn ON pn.Part_Number_ID =
pd.Part_Number_ID
WHERE pn.Part_Number = '6201011'
GROUP BY pn.Part_Number, pn.Purchasing_Factor, pd.Unit_Cost
当前,它为我提供了单价每次更改的最新日期,而不仅仅是最新日期。我觉得我需要一个内部联接或子查询,但是我什么都无法工作。任何帮助将不胜感激。