add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE table1 (
`id` INTEGER,
`date` Date,
`product` VARCHAR(1)
);

INSERT INTO table1
(`id`, `date`, `product`)
VALUES
('1', '2010-02-01', 'c'),
('1', '2010-02-02', 'v'),
('1', '2010-02-03', 'd'),
('1', '2010-02-04', 'g'),
('2', '2010-02-03', 'h'),
('2', '2010-02-04', 'w'),
('2', '2010-02-05', 't'),
('2', '2010-02-06', 'd'),
('3', '2010-02-04', 'x'),
('3', '2010-02-05', 'f'),
('3', '2010-02-06', 'x');
SELECT `id`, `date`, `product`
, FIRST_VALUE(`product`) OVER(PARTITION BY `id` ORDER BY `date` ROWS UNBOUNDED PRECEDING) minproduct
FROM table1
id date product minproduct
1 2010-02-01 c c
1 2010-02-02 v c
1 2010-02-03 d c
1 2010-02-04 g c
2 2010-02-03 h h
2 2010-02-04 w h
2 2010-02-05 t h
2 2010-02-06 d h
3 2010-02-04 x x
3 2010-02-05 f x
3 2010-02-06 x x