Home » Other » Training & Certification » Combination Function (PLSQL Functions)
Combination Function [message #359911] Tue, 18 November 2008 15:07 Go to next message
Messages: 1
Registered: November 2008
Location: Texas
Junior Member
I am new to PLSQL but I've been given a task to write a function that checks to see if there are more than 1 possible combination of transaction_ids whose total amount adds up to a specified amount.


transaction_id AMOUNT
1111 $20.00
2222 $25.00
3333 $25.00
4444 $50.00
5555 $150.00
6666 $180.00

Charge is to find out if there is more than one possible combinations of transaction_ids that adds up to $200.00 (
e.g 25+25+150 or 50+150 or 20+180
If there is only one combination, then return the transaction Ids that adds up to $200.00

Any ideas or suggestions will be greatly appreciated.

Re: Combination Function [message #359950 is a reply to message #359911] Tue, 18 November 2008 23:17 Go to previous messageGo to next message
Messages: 18
Registered: November 2008
Junior Member
you would probably need some type of loop for this. A loop to step through the transaction list and maybe then add till you either get to the predetermined amount or if it goes over to step onto the next transaction.
Re: Combination Function [message #359954 is a reply to message #359950] Tue, 18 November 2008 23:30 Go to previous message
Messages: 9
Registered: November 2008
Location: India
Junior Member
You can use two loops. In one loop you can take one Amount and in another loop you can sum it with other Amounts till you reach the Sum of 200.
Previous Topic: material
Next Topic: OCA 1Z0-042 exam question categories
Goto Forum:

Current Time: Sun Jul 12 11:44:49 CDT 2020