Hi, im struggling to move the where statement to the end of the query so I don't need to use it within each select? Is it possible as I cant figure it out?
Code:
SELECT X.[Item Code], X.[Highest Price], Y.[Last Price] FROM
(SELECT TOP 1 T0.[ItemCode] AS [Item Code], T1.[Price] AS [Highest Price] FROM OITM T0 INNER JOIN INV1 T1 ON T0.ItemCode = T1.ItemCode WHERE T0.[ItemCode] = '12345' ORDER BY T1.[Price] DESC) X
INNER JOIN
(SELECT TOP 1 T0.[ItemCode] AS [Item Code], T1.[Price] AS [Last Price] FROM OITM T0 INNER JOIN INV1 T1 ON T0.ItemCode = T1.ItemCode WHERE T0.[ItemCode] = '12345' ORDER BY T1.[DocDate] DESC) Y
ON X.[Item Code] = Y.[Item Code]
Many thanks
Brian