itemcode : VARCHAR
date : DATE
qty : INT
remainder_after : INT
itemcode date qty remainder_after
normal 2017-01-01 1 10
normal 2017-02-01 2 9
normal 2017-03-01 3 8
old 2017-01-01 4 7
new 2017-03-01 5 6
SELECT T.*
FROM (SELECT
itemcode,
max(date) AS date
FROM T
WHERE date <= '2017-02-15'
GROUP BY itemcode) AS A
JOIN T USING (itemcode, date);