我可以使用这个来获取所需的格式:
SELECT TO_CHAR(12345,'99G999') "Amount" FROM DUAL;
SELECT TO_CHAR(123456,'999G999') "Amount" FROM DUAL;
SELECT TO_CHAR(1234567,'9G999G999') "Amount" FROM DUAL;
是否有一种方法可以不像这样检查长度?
select case
when length(my_number) = 5 then TO_CHAR(my_number,'99G999')
when length(my_number) = 6 then TO_CHAR(my_number,'999G999')