Here is an outline. The first part sets up the tables and add the sample data. Preferably, you should have included this yourself.
SET NOCOUNT ON
go
CREATE TABLE customerorder (orderid int NOT NULL,
date date NOT NULL,
qty int NOT NULL,
prodorder int NULL,
CONSTRAINT pk_customerorder PRIMARY KEY (orderid)
)
INSERT customerorder(orderid, date, qty)
VALUES(1, '20200101', 2),
(2, '20200103', 9),
(3, '20200104', 12),
(4, '20200105', 2),
(5, '20200106', 3),
(6, '20200107', 5),
(7, '20200108', 3),
(8, '20200109', 4)
go
-- Solution starts here.
DECLARE @prodorder int = 1,
@sum int = 0,
@orderid int,
@qty int,
@threshold int = 10,
@cur CURSOR
SET @cur = CURSOR STATIC FOR
SELECT orderid, qty
FROM customerorder
ORDER BY date, qty
OPEN @cur
WHILE 1 = 1
BEGIN
FETCH @cur INTO @orderid, @qty
IF @@fetch_status <> 0
BREAK
UPDATE customerorder
SET prodorder = @prodorder
WHERE orderid = @orderid
SET @sum += @qty
IF @sum >= @threshold
SELECT @prodorder += 1,@sum = 0
END
go
SELECT * FROM customerorder
go
DROP TABLE customerorder