Home > database >  Oracle or SQL stored procedures how to solve the knapsack algorithm
Oracle or SQL stored procedures how to solve the knapsack algorithm

Time:09-15

Oracle, how to solve the knapsack algorithm?
For example, the following test list fields have not fixed number of rows in the table, now give me a specific number, find out all possible the combination of the line, line up to time, such as
A list
1
2
3
4
5
6
7
8
Now can give specific values of 8, the combination are: 1,2,5; 1 and 4; 2, 6; 3, 5; 8

Specific value as the ginseng, output combination

CodePudding user response:

 
With t as (select level m from dual connect by level<=8)
Select substr (sys_connect_by_path (m. ', '), 2) the from t connect by nocycle piror m
  • Related