Using CTE recursion for STACKING splittable items into bins
问题 I created a minimalistic sample data for the purpose of studying and presenting this interesting task. Bellow is code to setup test tables. The task is to distribute items into pre-set bins , while: we cannot exceed maximum capacity of a bin item can (should) be split, if it exceeds the remaining bin capacity there's a bin (always first), which has "unlimited" (very high) capacity and anything that does not fit into regular bins has to end up here. While it is particular to this example, in