Hi, Sebastian Dan.
Try this query
Code |
---|
SELECT
Prices.StoreNo,
Prices.ArticleCode,
MAX(Prices.LastDateModified) AS LastDateModified
INTO LastPrices
FROM
Catalog.Prices AS Prices
GROUP BY
Prices.StoreNo,
Prices.ArticleCode
;
////////////////////////////////////////////////////////////////////////////////
SELECT
Prices.StoreNo,
Prices.ArticleCode,
Prices.ExchangeId,
Prices.FinalPrice,
Prices.LastDateModified
FROM
Catalog.Prices AS Prices
INNER JOIN LastPrices AS LastPrices
ON Prices.StoreNo = LastPrices.StoreNo
AND Prices.ArticleCode = LastPrices.ArticleCode
AND Prices.LastDateModified = LastPrices.LastDateModified |
Also I recommend use information register instead catalog. Virtual table "SliceLast" will simplify your query.
Code |
---|
SELECT
PricesSliceLast.Period AS LastDateModified,
PricesSliceLast.StoreNo,
PricesSliceLast.ArticleCode,
PricesSliceLast.ExchangeId,
PricesSliceLast.FinalPrice
FROM
InformationRegister.Prices.SliceLast AS PricesSliceLast |