I'm using the following query to get the latest price from each product between a certain date. In the table 'prices' every price change of a product is registered as a new row.
select max(date) , product_id, price from prices
where date between '2015-01-01' and '2015-12-31'
group by product_id, price
As a result I get all prices per product but I want one (the latest) price per product. Can anyone please tell me what's wrong in this query.
Thank you very much !