I have a table with multiple products. For each product, I am collecting an history of prices. Thus I have four columns:
- log_entry
- product_id
- product_price
- timestamp
Until now, I updated all prices at the same time. This lead to an easy query: In a subquery, I filtered the max timestamp and then got all prices and products.
Today I changed my update policy: I now update prices for products asynchronously. This means, when I use my old query, I only get a product-price-pair with the maximum timestamp.
How do I get the most current price/the maximum timestamp for every product in one query?