Im have a column number(9,2). This column contains dollar amounts, like 1.50, 2.75, 2, etc. Im converting these amounts to spell them out like on a check. Ive got this far:
select debit, decode(sign(substr(debit, 1, (instr(debit,'.')-1))),-1,'Negative', 0, 'Zero', NULL)||
decode(sign(abs(substr(debit, 1, (instr(debit,'.')-1)))),+1,to_char(to_date(abs(substr(debit, 1, (instr(debit,'.')-1))),'J'),'Jsp'))||' Dollars' dollars
from gaccounts
where debit is not null
The problem i have now is that the select doesnt work if the col contains a whole dollar amount and no decimal for the instr to find. Im starting to think that by the time i work that out and THEN handle the right side of the decimal that this solution will be too convoluted. Can anybody point me to a simpler solution?
select debit, decode(sign(substr(debit, 1, (instr(debit,'.')-1))),-1,'Negative', 0, 'Zero', NULL)||
decode(sign(abs(substr(debit, 1, (instr(debit,'.')-1)))),+1,to_char(to_date(abs(substr(debit, 1, (instr(debit,'.')-1))),'J'),'Jsp'))||' Dollars' dollars
from gaccounts
where debit is not null
The problem i have now is that the select doesnt work if the col contains a whole dollar amount and no decimal for the instr to find. Im starting to think that by the time i work that out and THEN handle the right side of the decimal that this solution will be too convoluted. Can anybody point me to a simpler solution?