Syntactical Mistake:
Main Topics
Browse All TopicsI need to come up with the pl/sql query that will produce a record that has a summed amount for each code and term per person, so that the result set would look something like:
John, TU, SU, 0002500
John, OF, SU, 0005000
John, TU, WI, 0001000
John, TU, AU, 0003030
Mike, OF, SP, 0040050
(note: I need the amount to be 7 char long and include cents but no decimal point)
(note: you will need to decode 2 sets of values:
for the Term - 200701, the return should be SU, for 200702, AU, 200703, WI, 200704, SP
for the code, TU01, TU03, TU04 should return TU, REGF should be OF)
Here are my tables and data
(User)
Id, Name
1, John
2, Mike
(Charges)
Id, Code, Term, Amount
1, TU04, 200701, 10.00
1, TU01, 200701, 15.00
1, REGF, 200701, 50.00
1, TU03, 200703, 5.50
1, TU01, 200703, 4.50
1, TU04, 200702, 30.30
2, REGF, 200704, 200.50
2, REGF, 200704, 200.00
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
rrjegan17,
I think this will work out great!
On a side note, I am trying to do something similar with another script, however I know I have something wrong, but not sure what.
The problem I am having is when the sum occurs, it is summing all the TU values, regardless of what term they are actually in.
I think I may need an additional select and move some things around, but with adding in the other selects into this mix, I am not sure what I need or where??
Business Accounts
Answer for Membership
by: rrjegan17Posted on 2009-03-09 at 10:13:11ID: 23837988
Try out this query:
Select allOpen in new window