SQL 将每个数字的金额转换为单词(包括美元、小数和逗号)

SQL convert amount into word for each digit (including dollar, decimal, and comma)

我正在尝试通过 oracle SQL 将每个数字的大笔金额转换为单词。例如: 555,555,555.55 美元 = "dollar five five five comma five five five comma five five five period five five"。

我尝试了 Julian Date 版本的将数字转换为单词,但它只能达到万位,不会更大。

请帮忙。

您可以使用嵌套替换:

select replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(col, '$', 'dollar '
                                                                                                      ), ',', 'comma '
                                                                                              ), '0', 'zero '
. . .                                                                                                                                     

Results Image 好吧,我的语法可能有误,但它在我的结果中强制出现了一个奇数列,这是我的代码:

    SELECT SUM (amount) AS amount,
   REPLACE (
      REPLACE (
         REPLACE (
            REPLACE (
               REPLACE (
                  REPLACE (
                     REPLACE (
                        REPLACE (
                           REPLACE (
                              REPLACE (
                                 REPLACE (
                                    REPLACE (SUM (amount),
                                             '$',
                                             'dollar '),
                                    ',',
                                    'comma '),
                                 '.',
                                 'period '),
                              '0',
                              'zero '),
                           '1',
                           'one '),
                        '2',
                        'two '),
                     '3',
                     'three '),
                  '4',
                  'four '),
               '5',
               'five '),
            '6',
            'six '),
         '7',
         'seven '),
      '8',
      'eight '),
   '9',
   'nine '