- 1
- 2
- 3
- 4
- 5
SELECT p1.Id, p1.Type, p1.Price FROM `price-log` AS p1
JOIN (
SELECT Id, Type, MIN(Change_date) AS Change_date FROM `price-log`
WHERE Change_date > DATE_ADD(NOW(), INTERVAL -1 MONTH) GROUP BY Id, Type) AS p2 ON
p1.Id = p2.Id AND p1.Type = p2.Type AND p1.Change_date = p2.Change_date;