with a as(
select 'A' AS A,19 AS B,10 min_qty
UNION ALL
select 'B' AS A,10 AS B,10
)
select a.a,MIN_QTY,SEQ,a.b
,case when MIN_QTY * rnk < b THEN MIN_QTY ELSE b-MIN_QTY*(rnk-1) END AS NEW_QTY
from (
select a.a,a.b,MIN_QTY,count(MIN_QTY) over ( partition by a ) as SEQ,b.number + 1 as rnk
from a
CROSS join master..spt_values b
where b.number * a.MIN_QTY <= a.B and b.Type = 'P'
) a