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!

splitting the dollar amount in SQL

Ann 81Aug 14 2020 — edited Aug 14 2020

I am struggling to split dollar amount equally in 4 parts and inserting the rows in the table.

This is what I want . Suppose I have $88.13 ( which is 88 dollars and 13 cents) I need to have sql script which split it equally and if there is any remaining penny balance it should go to the maximum sequence while inserting to the table.

For Eg:

create table split_dollar(seq number, amount number(12,2));

insert into split_dollar (seq,amount) VALUES (1,22.03);

insert into split_dollar (seq,amount) VALUES (2,22.03);

insert into split_dollar (seq,amount) VALUES (3,22.03);

insert into split_dollar (seq,amount) VALUES (4,22.04);

SQL> select * from split_dollar;

       SEQ     AMOUNT

---------- ----------

         1      22.03

         2      22.03

         3      22.03

         4      22.04

Please let me know how I can achieve this.

Thanks,

Ann

This post has been answered by L. Fernigrini on Aug 14 2020
Jump to Answer
Comments
Post Details
Added on Aug 14 2020
8 comments
702 views