Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Finding all possible combinations of numbers to reach a given sum

Skp_OracleApr 15 2016 — edited Apr 20 2016

Hi All,

I am trying to solve a balancing problem in my application.

need to come up with PLSQL programs which find outs numbers which sums up to a target number.

I have 4000 rows of numbers and have to come up with the rows which sums up to a target number.

for eg ..

select NUMBERS from table1

and result of select is as below .

1.00

2.00

3.00

4.00

5.00

6.00

7.00

8.00

9.00

10.00

lets say my target number is 5  ..

once I input the above results into PLSQL program

the result/ dbms  should come up as

your possible number can be

2.00+ 3 .00

1.00 +4.00

this has been discussed  over internet in M S Excel forums  and using a solver add ons  , but i am trying to see if we have PLSQL way of finding this out using loops.

the numbers can be positive or negative but it always be the sum which we will be doing.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 18 2016
Added on Apr 15 2016
26 comments
6,508 views